#ifdef _WIN32 not getting detected
#ifdef _WIN32 #ifdef _WIN64
These are pre-defined macros defined by the MSVC compiler. You appear to be using g++
instead. That probably means either MinGW, or Cygwin.
Here and here are collections of macros pre-defined by several compilers.
MinGW
__MINGW32__
Cygwin
__CYGWIN__
If you prefer to not to build hefty ifdef - else trees, and scour the internet for macros defined by obscure compilers, and their different versions, I recommend to instead include a few headers from boost. They have already done the hard part of the work. Although, note that BOOST_OS_WINDOWS
is separate from BOOST_OS_CYGWIN
.
Use __CYGWIN32__
to detect Windows when compiling g++ in cygwin. (This is defined in both 32 and 64 bit).
_WIN32
&c. may not be defined in that case. It isn't for me.
(As also mentioned in a comment; using echo | g++ -dM -E
to output the list of what is defined can be helpful.)