64 bit Cygwin target and _WIN64

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Jul 18 14:42:00 GMT 2012

On Jul 18 09:44, Christopher Faylor wrote:
> On Wed, Jul 18, 2012 at 02:55:41PM +0200, Corinna Vinschen wrote:
> >On Jul 18 08:36, Earnie Boyd wrote:
> >> On Wed, Jul 18, 2012 at 7:03 AM, Corinna Vinschen wrote:
> >> > Now comes the time for _WIN64.  _WIN64 is used a *LOT* inside of the
> >> > Mingw64 headers to distinguish type definitions which differ from the
> >> > 32 bit version, or to declare functions which only exist on 64 bit
> >> > machines, stuff like that.
> >> 
> >> Is it needed always or just during compilation of Cygwin? (but read on
> >> before answering)
> >
> >The _WIN64 define is needed for building Cygwin as well as for building
> >Cygwin applications accessing the Windows API.
> Why would we worry about hypothetical nonexistent people who are trying
> to build a 64-bit Cygwin app with 64-bit Windows headers?  Couldn't we

It's hypothetical at this point, but it's not hypothetical as soon as
the first Cygwin/Windows mixed application is supposed to be ported to
64 bit Cygwin.  The problem with _WIN64 is not that it will be used
inside of an application, but that it is used inside the Windows headers,
for instance to create different structure layouts depending on running
on 32 or 64 bit Windows.  Typical example, just one of many:

  #if defined(_WIN64)
    typedef struct DECLSPEC_ALIGN(16) _SLIST_HEADER {
      ULONGLONG Alignment;
      ULONGLONG Region;

    typedef struct _SLIST_HEADER *PSLIST_HEADER;
    typedef union _SLIST_HEADER {
      ULONGLONG Alignment;
      __C89_NAMELESS struct {
        SLIST_ENTRY Next;
        WORD Depth;
        WORD Sequence;

> just tell them "Define _WIN64_ somewhere if you want to do this" ?  And
> then we could use -D_WIN64_ on the Cygwin command line.
> I think making this somewhat hard might actually help clarify that, when
> building an app, Cygwin should not be conflated with Windows.

Why do you want to make life harder for Andy or Jon or Yaakov?  Mintty
or the X server are valid applications which we're happy to exist while
they having a perfectly good reason to include Windows headers.

The big difference between _WIN64 and _WIN32 is that _WIN32 is just
some abused compiler-defined variable, while _WIN64 is needed inside
the Mingw64 headers to distinguish different definitions based on the

So, while we don't need the _WIN64 as a default setting in the compiler,
it should be taken care of inside the Windows headers to not treat Cygwin
applications wrong just because they are built for the 64 bit target.


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