Closed DanRStevens closed 1 year ago
That matches what I recently read.
It seems the underscore is for the implementation reserved namespace, which means compilers can define it by themselves, whereas the non-prefixed version would need to be set in source code or project compiler config settings. That seems to be how MSVC handles the two. The _WIN32
value is defined by the compiler, whereas the WIN32
value is defined in <windows.h>
. Obviously this makes it silly to use WIN32
as a check for including <windows.h>
.
Also, as a side note, the last answer mentions that MingW defines WIN32
automatically, unless you use -std=c++??
, like we do (-std=c++20
). I was able to confirm that behaviour by dumping compiler defines.
https://stackoverflow.com/questions/2224334/gcc-dump-preprocessor-defines
echo | x86_64-w64-mingw32-g++ -dM -E -x c++ -
echo | x86_64-w64-mingw32-g++ -dM -E -x c++ -std=c++20 -
This potentially matters for a Linux build using MingW, since the Linux filesystem is case sensitive. However, currently the MingW build does not trigger the Windows compile path here. Perhaps a sign the defines being checked here are a bit imprecise.
Reference: https://github.com/OutpostUniverse/OPHD/pull/1305#issuecomment-1509181851