[Wine] The __WINE__ macro does not identify the Wine platform

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed Jun 16 18:38:22 CDT 2010

According to some old discussion
(http://www.mail-archive.com/[email protected]/msg15669.html) on
wine-devel it appears that __WINE__ should be the macro used to
identify the Wine platform,

However, that doesn't appear to work for Windows native MinGW on wine.

Here is my test code:

#include <stdio.h>

int main(int argc, char** argv)
#if defined(__WINE__)
   printf("hello, WINE world\n");
   printf("hello, non-WINE world\n");
   return 0;

wine at raven> wine gcc --version
gcc.exe (GCC) 4.5.0
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
wine at raven> wine gcc test.c
wine at raven> wine ./a.exe
hello, non-WINE world

I have downloaded and unpacked the Windows version of MinGW (version 4.5.0),
and the above gcc --version result shows that is the version
being used under wine.

I have looked in the installed header files for wine-1.2-rc3, and I can find
no mention of __WINE__.  Furthermore, it appears from
http://linux.die.net/man/1/winegcc that only wingcc sets __WINE__. However,
I don't want to cross-compile for the Wine platform under Linux. Instead, my
approach is to use Windows versions of MinGW and CMake to build _AND_ test
applications and libraries directly under wine.

So it appears for now I must set __WINE__ explicitly, e.g.,

wine at raven> wine gcc -D__WINE__ test.c
wine at raven> wine ./a.exe
hello, WINE world

but the issue is that should happen automatically instead.

Is there some better macro I should be using to identify when a build
is occurring on the wine platform?

Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project

Linux-powered Science

More information about the wine-users mailing list