This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
Re: 64 bit Cygwin target and _WIN64
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.
> > There are a couple of ways to help us along with this problem:
> >
> > 1. Replace all
> >
> > #ifdef _WIN64
> >
> > with
> >
> > #if defined (_WIN64) || defined (__CYGWIN64__)
> >
>
> Ugly, what happens now with _WIN32 headers?
Nothing. The Windows headers don't test for _WIN32 since it's assumed
to be always defined anyway.
> > 2. In a core Mingw64 header:
> >
> > #if defined (_WIN64) || defined (__CYGWIN64__)
> > #define _WINX64
> > #endif
> >
> > Then replace all `#ifdef _WIN64' with `#ifdef _WINX64'.
>
> I don't see this happening; too easy to break.
That's my primary concern, too.
> > 3. In a core Mingw64 header:
> >
> > #ifdef __CYGWIN64__
> > #define _WIN64
> > #endif
> >
>
> If you only need _WIN64 defined during the Cygwin build then put this
> in a Cygwin local definition else put it in the mingw64 headers.
Mingw64 header is the answer then. I can hack as I like when tweaking
Cygwin, so the way we handle _WIN64 is of concern mostly to Cygwin
applications using Windows functions. Mintty, X server, you name it.
> > Consequentially, projects for which testing for _WIN64 is an important
> > design choice are windows-centric anyway and probably no serious target
> > for a Cygwin port.
> >
>
> Maybe not always though. As _WIN64 specifics begin to creep into
> those now supporting _WIN32.
Thing is, an application which calls two different Windows functions
depending on _WIN64 needs the _WIN64 define anyway when building its
code. So, if we define _WIN64 from within the Windows headers, we
might even help the project along.
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
And since Cygwin doesn't provide _WIN32, we will be default still not
call the Windows functions, even on 64 bit with _WIN64 defined if a
WIndows header is included.
> > Given that, I am inclined to simplify the problem by choosing point 3;
> > just define _WIN64 if a Windows header is included and then keep it
> > at that.
> >
>
> I like this. If it is always needed then do it in the mingw64 headers
> otherwise do it locally.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat