簡體   English   中英

檢查編譯器是否是Turbo C ++

[英]Check if compiler is Turbo C++

我目前正在處理為Turbo C ++設計的遺留代碼。 要解決Turbo C ++缺少bool數據類型的問題,該程序包含以下代碼行。

// Necessary when compiling with Turbo C++
enum bool {false, true};

大多數C ++編譯器都無法運行帶有error: expected identifier before 'bool'的程序error: expected identifier before 'bool' 雖然我希望切換到更新的編譯器,但遺憾的是我需要維護此解決方法以實現向后兼容性。

我怎么能指出這個特定的代碼行只能在Turbo C ++中編譯?

正如Thomas Matthewsselbie在評論中所建議的那樣:

#ifdef __TURBOC__
    // Only runs if compiler is Turbo C++
    enum bool {false, true};
#endif

資料來源: http//beefchunk.com/documentation/lang/c/pre-defined-c/precomp.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM