Search code examples
gcccygwingcc-warning

Compiler errors building using Cygwin and GCC


I am trying to build an open source package on Windows using Cygwin and GCC. I am getting errors like the following and none of the solutions I have found elsewhere on StackOveflow have resolved the issues:

/usr/include/w32api/psdk_inc/_fd_types.h:100:2: error: #warning "fd_set and associated macros have been defined in sys/types.      This can cause runtime problems with W32 sockets" [-Werror=cpp]

Having spent several hours Googling and searching here without success I would really appreciate any help.

Sid


Solution

  • After more experimentation it appears that the code required some additional conditional compilation control. I added a check for the Cygwin environment around a couple of places in the code. Previously only the "_WIN32" was there:

    #if !defined(_WIN32) && !defined(__CYGWIN__)
    #   include <sys/socket.h>
    #   include <netinet/in.h>
    #   include <netinet/tcp.h>
    #   include <sys/select.h>
    #else
    #   include <winsock2.h>
    #   include <windows.h>
    #   include <ws2tcpip.h>
    #endif
    

    Sid