Subject: Re: Version 1.8.1 does not compile on Cygwin 1.7.14

From: Mark Levedahl <[email-masked]>
Date: Fri, 25 Jan 2013 18:58:59 -0500

On 01/22/2013 01:31 PM, Ramsay Jones wrote:
> include order. ;-) As I have mentioned here before, the claim that 
> "WIN32 is not defined on cygwin" is simply nonsense - it depends on 
> if/when certain header files are included. For example, *as soon as* 
> you include <windows.h> (and, I suspect, many other win32 headers) 
> then "defined(WIN32)" is true. Note that commit 380a4d92 ("Update 
> cygwin.c for new mingw-64 win32 api headers", 11-11-2012) swaps the 
> include order for the win32.h and git-compat-util.h header files. [I 
> don't know the details, Mark didn't elaborate, but it is clearly an 
> include order problem on cygwin 1.7.x :-D ] This causes compilation 
> errors on cygwin 1.5.x, exactly because win32.h includes <windows.h>, 
> which defines WIN32, which then leads to git-compat-util.h including 
> <winsock2.h>.
>>   #if defined(WIN32) && defined(__CYGWIN__)
>>   # undef WIN32
>>   #endif
>
Cygwin and Windows should be treated as completely separate platforms: 
if __CYGWIN__ is defined, do one thing, if not, go ahead and check 
WIN32, but the WIN32 macro should never be tested once we know the 
platform is CYGWIN - these really are different platforms (if you are 
unsure of this, consider that Cygwin includes a cross-compiler to target 
native Win32 as the Cygwin maintainers recognized the platforms are 
different).

Mark