How to use #ifdef entities as part of functions in header files

Posted by Crazyjavahacking on Stack Overflow See other posts from Stack Overflow or by Crazyjavahacking
Published on 2012-03-20T11:25:41Z Indexed on 2012/03/20 11:29 UTC
Read the original article Hit count: 188

Filed under:
|

I would like to ask if it is possible to use the entities defined in #ifdef block in header files. To be clear, I have following code:

#ifdef
    #include <winsock2.h>

    #define SOCKET_HANDLE     SOCKET
    #define CONNECTION_HANDLE SOCKET
#endif


SOCKET_HANDLE createServerSocket(const char* hostAddress, short port);

I am Java developer and this seems completely fine for me. However compiler has a problem with this.

Can you explain why is that code a problem? Also how can I force to compile it. (The idea is to have generic interface and conditional compilation to determine real types according to running platform at compile time.)

Thanks

© Stack Overflow or respective owner

Related posts about c

    Related posts about header