久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 C 預處理器中可靠地檢測 Mac OS X、iOS、L

How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor?(如何在 C 預處理器中可靠地檢測 Mac OS X、iOS、Linux、Windows?)
本文介紹了如何在 C 預處理器中可靠地檢測 Mac OS X、iOS、Linux、Windows?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如果有一些跨平臺的 C/C++ 代碼應該在 Mac OS X、iOS、Linux、Windows 上編譯,我如何在預處理過程中可靠地檢測它們?

If there's some cross-platform C/C++ code that should be compiled on Mac OS X, iOS, Linux, Windows, how can I detect them reliably during preprocessor process?

推薦答案

有大多數編譯器使用的預定義宏,你可以找到列表 此處.GCC 編譯器預定義宏可以在此處找到.以下是 gcc 的示例:

There are predefined macros that are used by most compilers, you can find the list here. GCC compiler predefined macros can be found here. Here is an example for gcc:

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
   //define something for Windows (32-bit and 64-bit, this part is common)
   #ifdef _WIN64
      //define something for Windows (64-bit only)
   #else
      //define something for Windows (32-bit only)
   #endif
#elif __APPLE__
    #include <TargetConditionals.h>
    #if TARGET_IPHONE_SIMULATOR
         // iOS Simulator
    #if TARGET_OS_MACCATALYST
         // Mac's Catalyst (ports iOS API into Mac, like UIKit).
    #elif TARGET_OS_IPHONE
        // iOS device
    #elif TARGET_OS_MAC
        // Other kinds of Mac OS
    #else
    #   error "Unknown Apple platform"
    #endif
#elif __linux__
    // linux
#elif __unix__ // all unices not caught above
    // Unix
#elif defined(_POSIX_VERSION)
    // POSIX
#else
#   error "Unknown compiler"
#endif

定義的宏取決于您要使用的編譯器.

The defined macros depend on the compiler that you are going to use.

_WIN64 #ifdef 可以嵌套到_WIN32 #ifdef 因為_WIN32code> 甚至在面向 Windows x64 版本時定義.如果某些標頭包含對兩者通用,則這可以防止代碼重復(也WIN32 沒有下劃線允許IDE 突出顯示代碼的正確分區).

The _WIN64 #ifdef can be nested into the _WIN32 #ifdef because _WIN32 is even defined when targeting the Windows x64 version. This prevents code duplication if some header includes are common to both (also WIN32 without underscore allows IDE to highlight the right partition of code).

這篇關于如何在 C 預處理器中可靠地檢測 Mac OS X、iOS、Linux、Windows?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Algorithm to convert RGB to HSV and HSV to RGB in range 0-255 for both(將 RGB 轉換為 HSV 并將 HSV 轉換為 RGB 的算法,范圍為 0-255)
How to convert an enum type variable to a string?(如何將枚舉類型變量轉換為字符串?)
When to use inline function and when not to use it?(什么時候使用內聯函數,什么時候不使用?)
Examples of good gotos in C or C++(C 或 C++ 中好的 goto 示例)
Significance of ios_base::sync_with_stdio(false); cin.tie(NULL);(ios_base::sync_with_stdio(false) 的意義;cin.tie(NULL);)
Is TCHAR still relevant?(TCHAR 仍然相關嗎?)
主站蜘蛛池模板: 性色av香蕉一区二区 | 毛片入口| 成人午夜视频在线观看 | 亚州中文| 操操日| 精品粉嫩超白一线天av | 亚洲国产精品久久久 | 一级黄色毛片子 | 久久亚洲国产精品 | av高清 | 欧美大片一区 | 成人3d动漫一区二区三区91 | 亚洲精品久久久久久久久久久 | 欧美精品中文字幕久久二区 | 国产69精品久久99不卡免费版 | 久久精品国产一区二区电影 | 中文字幕第十五页 | 区一区二在线观看 | 欧美日韩在线综合 | 天天操天天射天天舔 | 欧美日一区| 天天操天天拍 | 中文字幕av一区 | 免费看国产一级特黄aaaa大片 | 草久视频 | 欧美中文一区 | 亚洲美女一区二区三区 | 亚洲欧美一区二区三区在线 | 在线观看日本高清二区 | 亚洲一区二区三区国产 | 男人的天堂中文字幕 | 亚洲国产精品99久久久久久久久 | 欧美日韩精品一区二区 | 欧美精品综合在线 | 久久中文一区二区 | 91久操视频 | 欧美极品在线播放 | 国产成人免费视频网站视频社区 | 99亚洲精品视频 | 国产欧美一区二区在线观看 | 国产二区三区 |