Dear Luis, Thanks for the report, should be fixed in SVN 24333 by moving all WINDOWS macro tests to #ifdef/#ifndef.
Happy hacking! Christian On 10/16/2012 12:19 AM, luis garcia wrote: > Hi, > > When I compile the library with the c compiler instead of c++ i get errors > due to mix use of #if and #ifdef WINDOWS. > > I will give an example. I compile the library for Linux environment. If I > try to compile having WINDOWS undefined the build will failed whenever > daemon.c expects WINDOWS to be defined. Here are couple examples: > > /* make socket non-inheritable */ > #if WINDOWS > DWORD dwFlags; > > and > > #if !WINDOWS > flags = fcntl (fd, F_GETFD); > if (flags < 0) > > among others. > > So then I proceed to define WINDOWS to 0 in MHD_config.h > #define WINDOWS 0 > > Although this does not cause build problems in daemon.c there are issues > since now WINDOWS is defined. Therefore code like the one below will act as > if the library was built for WINDOWS: > > #ifdef IPV6_V6ONLY > /* Note: "IPV6_V6ONLY" is declared by Windows Vista ff., see > "IPPROTO_IPV6 Socket Options" > > (http://msdn.microsoft.com/en-us/library/ms738574%28v=VS.85%29.aspx); > and may also be missing on older POSIX systems; good luck if you > have any of those, > your IPv6 socket may then also bind against IPv4... */ > #ifndef WINDOWS > const int on = 1; > setsockopt (socket_fd, > IPPROTO_IPV6, IPV6_V6ONLY, > &on, sizeof (on)); > #else > const char on = 1; > setsockopt (socket_fd, > IPPROTO_IPV6, IPV6_V6ONLY, > &on, sizeof (on)); > #endif > #endif > > and > > /** > * Default connection limit. > */ > #ifndef WINDOWS > #define MHD_MAX_CONNECTIONS_DEFAULT FD_SETSIZE - 4 > #else > #define MHD_MAX_CONNECTIONS_DEFAULT FD_SETSIZE > #endif > > > Finally plibc.h uses #ifdef WINDOWS and if WINDOWS is defined even to 0 it > assumes that you are using windows. Which will cause a whole set of issues > when you are not actually targeting windows. Looking at the code I realized > that plibc is only intended to be used and compiled when targeting windows, > but confirmation of this will be appreciated. > > Thanks for any comments on this matter. > > Luis >
