Visual Studio与GCC,关于"' __ cdecl'属性指令被忽略[-Wattributes]"

时间:2017-10-04 21:15:58

标签: c visual-studio gcc

我需要在Visual Studio中禁止GCC(或我认为是GCC)编译器警告。通常这些Visual Studio编译器警告带有警告代码,但这个警告代码只是null。

警告为'__cdecl' attribute directive ignored [-Wattributes]。我相信我需要为我的.h文件禁止所有-Wattributes警告,但我不知道该怎么做。

给我带来麻烦的块在 LoggerHelper.h 里面:

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

1 个答案:

答案 0 :(得分:1)

GCC的cdecl属性没有前导下划线,声明应如下所示:

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