Are you sure there's nothing undefining WIN32? My installation of MinGW (4.6.1 at this site) definitely defines it:
C:\temp>gcc -E -dM test.c | find /i "win" #define _WIN32 1 #define __WINT_MAX__ 65535 #define _WINT_T #define __WINT_MIN__ 0 #define __WIN32 1 #define __WINNT 1 #define __WINNT__ 1 #define __WIN32__ 1 #define __SIZEOF_WINT_T__ 2 #define WIN32 1 // <-- right here #define __WINT_TYPE__ short unsigned int #define WINNT 1
Try passing the -E -dM options to verify if your MinGW compiler is (or isn't) pre-defining the WIN32 macro.
Note that strictly speaking, WIN32 should not be predefined by the compiler (since it's in the user's namespace) - only _WIN32 should. WIN32 should be set by the SDK being used and/or by the build environment - that's the way it works in Microsoft's compilers.
For example, there's the following sequence in windef.h"
#ifndef WIN32 #define WIN32 #endif
and /D "WIN32" is put into Visual Studio C++ projects by default.
See https://stackoverflow.com/a/662543/12711 for more details.