How to tell if you're compiling on Windows?
Someth开发者_JAVA百科ing like:
#ifdef WINDOWS
// do stuff
#endif
The _WIN32 is always defined on Windows platform, checkout the predefined macros.
This is the most complete table I know of. https://sourceforge.net/p/predef/wiki/Compilers/
It depends on what files are you using.
The compiler itself doesn't have such a flag, but it is common to have such a define in the operating system's SDK.
For example, the CRT has a Win32 define, which affects how it is compiled.
I'm not entirely sure I understand the question but yes, you can do this. Obviously, you need to tell the compiler you're compiling on Windows (or operating system x) at compile time. I've seen a similar approach used for bit size of things like integers.
精彩评论