c_cpp C-编制上 - 窗口和Linux的IFDEF开关

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp C-编制上 - 窗口和Linux的IFDEF开关相关的知识,希望对你有一定的参考价值。

#include <stdio.h>
#include <stdlib.h>

#ifdef __linux__
    //linux code goes here
    #define SYS_INFO "linux"
#elif _WIN32
    // windows code goes here
    #define SYS_INFO "windows"
#else
    #define SYS_INFO "unknown"
#endif

int main()
{
    printf("Hello world!\n");
    printf("System info: %s.\n", SYS_INFO);
    return 0;
}

// ref: http://stackoverflow.com/questions/6649936/c-compiling-on-windows-and-linux-ifdef-switch

以上是关于c_cpp C-编制上 - 窗口和Linux的IFDEF开关的主要内容,如果未能解决你的问题,请参考以下文章