__linux__、__POSIX__宏

  __linux__用于定义linux,__POSIX__不太了解,各系统的宏有如下:

std::string getOsName()
{
    #ifdef _WIN32
    return "Windows 32-bit";
    #elif _WIN64
    return "Windows 64-bit";
    #elif __APPLE__ || __MACH__
    return "Mac OSX";
    #elif __linux__
    return "Linux";
    #elif __FreeBSD__
    return "FreeBSD";
    #elif __unix || __unix__
    return "Unix";
    #else
    return "Other";
    #endif
} 

 

posted on 2019-09-28 00:31  留校察看  阅读(2283)  评论(0编辑  收藏  举报

导航