64 bit Cygwin target and _WIN64

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Jul 19 08:40:00 GMT 2012

On Jul 18 18:15, Peter Rosin wrote:
> On 2012-07-18 14:55, Corinna Vinschen wrote:
> > On the other hand, an application which provides Windows and POSIX
> > functions will test for _WIN32 with a high probability:
> > 
> > #ifdef _WIN32
> > #ifdef _WIN64
> > call foo_win64
> > #else
> > call foo_win32
> > #endif
> > #else
> > call foo_posix
> > #endif
> Some would perhaps write that as:
> #if defiend _WIN64
> call foo_win64
> #elif defined _WIN32
> call foo_win32
> #else
> call foo_posix
> #endif

Yes, that's the possible danger.  But still, the chance that the Windows
headers are included guarded by an #ifdef _WIN32 are extremly high.  If
so, the _WIN64 will not be defined when compiling the code, considering
solution 3.  The chance to meet such an application seems to be pretty

I had a more or less sleepless night thinking about this stuff, but the
more I think about it, the more I think that just #defining _WIN64 in
the Windows headers if called from a x86_64-targeting Cygwin compiler is
the right thing to do.  On one hand a 64 bit Cygwin application will
get the correct Windows definitions, on the other hand the impact on the
Mingw64 headers is minimal.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

More information about the Cygwin-developers mailing list