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开关的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp 获取X窗口系统上的活动窗口

c_cpp 改变DOS窗口的背景和字体颜色

c_cpp 给出一个窗口大小K和一个大小为N的数组,找到每个窗口滑过数组时的最小值

c_cpp 窗口移动

c_cpp 这在Windows,Linux,* BSD和Mac OS X上提供了endian.h的endian转换函数。你仍然需要使用-std = gnu99代替

如何在Windows下编制与Linux系统对应的C语言gettimeofday函数