From: Christoph D. <chr...@hs...> - 2005-01-06 09:02:38
|
On Thu, 06 Jan 2005 02:00:15 -0500 Greg Chicares <chi...@co...> wrote: > On 2005-01-05 10:25 AM, HERNANDEZ CORDOBA RODRIGO JOSE wrote: > > > ["Christoph Dalitz" wrote] > > > >>while needing a conditional compilation for MingW32 I am wondering > >>whether there is a predefined macro (like __BORLANDC__ for bcc32) > >>indicating that the current compiler is mingw32. > >> > >>Or do I need to define this myself in the Makefile? > > > > I use: > > > > #if defined(__GNUC__) && defined(WIN32) > > > > #endif > > > > if you're only targeting Windows, you can do without the WIN32 Check. > > MinGW does predefine 'WIN32' > > C:/tmp[0]$touch foo.h; /MinGW/bin/cpp -dM foo.h |grep -w WIN32 > #define WIN32 1 > > so that's reliable with MinGW, although there's no > perfectly reliable macro to detect ms windows portably > AFAIK. I think Paul Grenyer's suggestion > > __MINGW32__ > > is the officially-recommended and best way. Would > > > #if defined(__GNUC__) && defined(WIN32) > > be true for cygwin as well? > Here is what I get on my win32 system with cygwin gcc 3.3 and minw gcc 2.95: bash:[tmp]> touch foo.h; D:/MingW32/bin/cpp -dM foo.h | grep -e 'GNU\|WIN32' #define WIN32 1 #define _WIN32 1 #define __WIN32__ 1 #define __WIN32 1 bash:[tmp]> touch foo.h; /usr/bin/cpp -dM foo.h | grep -e 'GNU\|WIN32' #define __CYGWIN32__ 1 It seems that none defines __GNUC__ and only MingW32 defines WIN32. Christoph |