I would like to write a cross-platform function in C++ that contains system calls. What conditional compilation flags can I check to determine which operating system the code is being compiled for? I'm interested mostly in Windows and Linux, using Visual Studio and GCC.
I think it should look something like this:
void SomeClass::SomeFunction()
{
// Other code
#ifdef LINUX
LinuxSystemCall();
#endif
#ifdef WINDOWS
WindowsSystemCall();
#endif
// Other code
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…