How do I check OS with a preprocessor directive?

前端 未结 16 1536
星月不相逢
星月不相逢 2020-11-22 13:53

I need my code to do different things based on the operating system on which it gets compiled. I\'m looking for something like this:

#ifdef OSisWindows
// do         


        
16条回答
  •  臣服心动
    2020-11-22 14:04

    #ifdef _WIN32
    // do something for windows like include 
    #elif defined __unix__
    // do something for unix like include 
    #elif defined __APPLE__
    // do something for mac
    #endif
    

提交回复
热议问题