Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Thu, 12 Jul 2001 11:15:04 -0700 (PDT) From: Mo DeJong To: cygwin AT sources DOT redhat DOT com Subject: Problem including Cygwin header files. Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hi all. I have run into a strange problem that seems to be some sort of incompatibility between Cygwin's header files and the header files used by VC++ and Gygwin with the -mno-cygwin flag. The problem shows up when #including the header: % cat t.c #include int main() { return 0; } It works just fine with VC++ or Cygwin in mingw mode: % cl -c t.c % gcc -c -mno-cygwin t.c But this blows up under Cygwin: % gcc -c t.c /usr/include/w32api/winsock.h:28: parse error before SOCKET /usr/include/w32api/winsock.h:28: warning: data definition has no type or storage class ... (The compiler errors go on after that) ... The line of code on line 28 of winsock.h is: typedef u_int SOCKET; The problem seems to be related to the include. If you add a "#include " to the top of t.c, it will compile as expected. Thing is, I am not sure if this is correct. If you poke around in winsock.h you will find some code like so: #if !defined( _BSDTYPES_DEFINED ) && !defined( _SYS_TYPES_H ) /* also defined in gmon.h and in cygwin's sys/types */ typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; #define _BSDTYPES_DEFINED #endif /* ndef _BSDTYPES_ _SYS_TYPES_H */ typedef u_int SOCKET; This block seems to want to define these u_* types when winsock.h is pulled in by itself. If you look at the /usr/include/sys/types.h file for Cygwin it includes a block that defines these types except in the case where is pulled in from the winsock.h file (when _WINSOCK_H) if defined. Thing is, the !defined( _SYS_TYPES_H ) check is not going to do this since is getting pulled in by the include of earlier in the file. At that point, I deleted the && !defined( _SYS_TYPES_H ) check and tried to compile things again. That fixed the first problem but I still get this error: % gcc -c t.c In file included from t.c:6: /usr/include/w32api/winsock.h:494: parse error before 'fd_set' Looking at the sys/types.h again, I found the following comment: "We don't define fd_set and friends if we are compiling POSIX source, or if we have included the Windows Sockets.h header (which defines Windows versions of them)." At this point I am kind of stuck. Am I on the right track with this earlier change? Is this some nasty incompatibility between the VC++ version of winsock.h and the w32api version? I am kind of at a loss about where to go from here, so if someone that knows a little more about these header file issues could give me a pointer it would really help. thanks Mo DeJong Red Hat Inc -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/