This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Integrating Win32 changes


Per Bothner wrote:
> > "#ifdef WIN32" would probably be better unless the code really depends
> > on Mingw32.  That'll benefit those who may be compiling with Cygwin or
> > U/WIN, or other GCC-on-Windows environments.
> 
> Remember that as a general rule we want to avoid conditional
> compilation using conditionals that test for specific hosts.  Instead,
> we want to use conditionals that test for specific *features*.  For
> example, when it comes to FileDescriptor, we don't want to test for
> WIN32 or Mingw32, but for something more specific that identifies the
> API.  After all, you might want to use Posix-style I/O on WIN32 (e.g.
> if you're running CygWin32), so #ifdef WIN32 would do the wrong thing.

One could argue that WIN32 is a "feature" too, meaning the Win32 API is
available.  In the case of Cygwin you have a choice.  In the case of
Interix (for example), WIN32 should _not_ be defined since Win32 is not
accessible (though it runs on NT).

Some time ago on the Cygwin mailing list it was debated that WIN32
should be dropped from the predefines, since the Cygwin environment
masquerades as POSIX, and configure scripts sometimes get confused.  The
project leaders decided that it makes sense to define both WIN32 and
__CYGWIN32__ to indicate that both API's are available.  I understand
their point, although it leads to a lot of pecularities like:

#if defined(WIN32) && !defined(__CYGWIN32__)
...
#endif

(Those running Linux should be happy they only have glibc issues to
worry about.)

-- 
Jeff Sturm
jsturm@sigma6.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]