gcc禁用几行代码的所有警告

时间:2022-09-06 08:08:13

I have the same problem as described by Jonathon Reinhart here: Temporarily disable gcc warning on redefinition

我有与Jonathon Reinhart在此描述的相同的问题:在重新定义时暂时禁用gcc警告

That is because I have to use thrid party libraries (C only) which throws tons of warnings like this

那是因为我必须使用第三方库(仅限C),它会抛出大量的警告

Warning "__always_inline" redefined [enabled by default]    

What I want is something like this:

我想要的是这样的:

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

Is there a way to disable warnings by gcc which are enabled by default with a

有没有办法通过gcc禁用警告,默认情况下使用a启用

#pragma GCC diagnostic ignored

EDIT: here is the block causing the warning (file: compiler.h):

编辑:这是导致警告的块(文件: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 个解决方案

#1


1  

I fixed it by undefining all lines where __always_inline was defined. :-( Thanks Jasen for helping!

我通过取消定义__always_inline定义的所有行来修复它。 :-(谢谢Jasen帮忙!

#1


1  

I fixed it by undefining all lines where __always_inline was defined. :-( Thanks Jasen for helping!

我通过取消定义__always_inline定义的所有行来修复它。 :-(谢谢Jasen帮忙!