我想用C++编写一个包含系统调用的跨平台函数.我可以检查哪些条件编译标志来确定编译代码的操作系统是什么?我主要对Windows和Linux感兴趣,使用Visual Studio和GCC.
我认为应该看起来像这样:
void SomeClass::SomeFunction()
{
// Other code
#ifdef LINUX
LinuxSystemCall();
#endif
#ifdef WINDOWS
WindowsSystemCall();
#endif
// Other code
}
Run Code Online (Sandbox Code Playgroud) linux windows cross-platform conditional-compilation visual-studio