baumann@pan wrote:
> hi all,
>
> i defined a macro like the below
>
>
> #define initSock() \
> do{\
> WSADATA ws_data;\
> WSAStartup(0x0202,&ws_data);\
> }while(0)
>
> then in a function , i wrote
>
> if(!initSock())
> {
> ....
> }
>
> but the compiler complains
> main.c
> e:\project\scanap\main.c(11) : error C2059: syntax error : 'do'
> e:\project\scanap\main.c(11) : error C2065: 'ws_data' : undeclared
> identifier
> e:\project\scanap\main.c(11) : warning C4133: 'function' : incompatible
> types - from 'int *' to 'struct WSAData *'
>
>
> if i change the macro to static function, it's ok.
Think of what the compiler `sees' in this case (remember that macros are
replaced, during the preprocessor phase of compilation, by their expansion).
[Your compiler may provide a way to see the intermediate, i.e.
preprocessed, code. Consult its documentation.]
HTH,
--ag
--
Artie Gold -- Austin, Texas
http://it-matters.blogspot.com (new post 12/5)
http://www.cafepress.com/goldsays