2015-01-03 70 views
9

我有同樣的問題,因爲由喬納森·萊因哈特說明如下: Temporarily disable gcc warning on redefinitionGCC禁用所有警告爲幾行代碼

那是因爲我必須使用THRID第三方庫(僅C),它拋出噸這樣

Warning "__always_inline" redefined [enabled by default]  

警告我想是這樣的:

#pragma GCC diagnostic push 
#pragma GCC diagnostic ignored "-W???" 
    #include "someheader.h" 
    #include "otherheader.h" 
#pragma GCC diagnostic pop 

有沒有一種方法來禁用警告通過GCC爲默認的有

#pragma GCC diagnostic ignored 

編輯啓用 這裏引起警告(文件:compiler.h):該塊

#if defined(__CC_ARM) 
# define __always_inline __forceinline 
#elif (defined __GNUC__) 
# define __always_inline inline __attribute__((__always_inline__)) 
#elif (defined __ICCARM__) 
# define __always_inline _Pragma("inline=forced") 
#endif 
+1

它是粗魯的他們使用這樣的保留的名字你有聯繫過庫的供應商嗎?你應該要求他們提供適合C編譯器使用的頭文件。可以用sed或類似的方式攻擊提供的頭文件,並將宏更改爲不使用保留名稱。 – Jasen

+7

「掃描地毯下的錯誤」似乎是對此問題的次優解決方案 – Jasen

+0

供應商(Atmel)獲悉:http: /asf.atmel.com/bugzilla/show_bug.cgi?id=3486你是對的,清理錯誤並不是最好的解決方案,但修復了一些錯誤,例如爲每個新版本的庫重新定義完全相同的* __ always_inline *行一次又一次更糟。 –

回答

1

我通過定義__always_inline被定義的所有行來定義它。 :-( 感謝Jasen的幫助!