簡體   English   中英

盡管有if語句,Visual Studio仍試圖包括Linux標頭

[英]Visual Studio trying to include linux headers despite if statement

我試圖創建一個健壯的頭文件,無需更改即可在Windows和Linux上進行編譯。 為此,我的include中有一個if語句,看起來像

#if (!defined(__WINDOWS__))
#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
#endif

盡管if語句導致出現類似錯誤,但Visual Studio仍在嘗試包含這些標頭的問題,

error C1083: Cannot open include file: 'sys/time.h'

有沒有一種方法可以解決此問題,而無需從標頭中刪除所有linux代碼塊?

__WINDOWS__windows.h定義。 因此,您具有圓度。 使用此代替:

#if defined(_WIN32)
#   if defined(_WIN64)
        /*64 bit windows*/
#   else
        /*32 bit windows*/
#   endif
#endif

是的,_WIN32 在64位窗口上定義的。 我不騙你

暫無
暫無

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

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