Using macros WIN32 or _MSC_VER cross-platform
This worked for me!
#if defined (_WIN32)
#define PLATFORM "Windows"
#elif defined (__linux)
#define PLATFORM "Linux"
#endif
#include <iostream>
using namespace std;
int main()
{
cout << PLATFORM << "System" << endl;
return 0;
}
There is no WIN32
. If you've seen it being used elsewhere, it's either wrong or the code is explicitly defining that macro itself somewhere.
You want _WIN32
. See https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros for a list of predefined macros in Microsoft's compiler.
Use _WIN32 instead. The IntelliSense parser in VS2008 is troublesome, this might not necessarily solve your problem. It got a complete rewrite in VS2010.