2017-10-04 188 views
0

我需要在Visual Studio中禁止GCC(或者我認爲是GCC)的編譯器警告。通常這些Visual Studio編譯器警告帶有一個警告代碼,但是這個只是null。Visual Studio vs GCC,關於'__cdecl'屬性指令被忽略[-Wattributes]「

警告是'__cdecl' attribute directive ignored [-Wattributes]。我相信我需要禁止所有-Wattributes警告我的.h文件,但我不知道如何做到這一點。

這是給我的煩惱塊裏面LoggerHelper.h

#ifdef _MSC_VER 
    using LoggerFuncPtr = void(__cdecl *)(wchar_t*); 
#else 
    using LoggerFuncPtr = void(__attribute__((__cdecl)) *)(wchar_t*); 
#endif 
+0

我認爲對於GCC,'cdecl'這個名稱與前面的下劃線一起使用。 –

+0

@MichaelBurr你知道我會怎樣去抑制它嗎?我是否需要在文件本身中包含一些抑制行,還是在Visual Studio中有一個可以切換/添加到列表的選項? – Ryan

+0

閱讀gcc的文檔?在命令行上,選項-Wxxx啓用警告xxx,-Wno-xxx禁用它。 –

回答

1

GCC的cdecl屬性沒有前導下劃線,聲明應該是這樣的:

#ifdef _MSC_VER 
    using LoggerFuncPtr = void(__cdecl *)(wchar_t*); 
#else 
    using LoggerFuncPtr = void(__attribute__((cdecl)) *)(wchar_t*); 
#endif