How can I hide “defined but not used” warnings in GCC?

前端 未结 8 1046
栀梦
栀梦 2020-12-04 09:45

I have a bunch of compile time asserts, such as:

CASSERT(isTrue) or CASSERT2(isTrue, prefix_)

When compiling with GCC I get many warnings l

相关标签:
8条回答
  • 2020-12-04 10:19

    This is hard to answer without knowing the details of your static assert macros. Perhaps you could change to a different macro to avoid this problem? You could either add the 'unused' attribute to the macro as was suggested, or you could use a different form of CASSERT().

    Here are descriptions of a few alternatives:

    http://www.jaggersoft.com/pubs/CVu11_3.html

    http://blog.kowalczyk.info/kb/compile-time-asserts-in-c.html

    http://www.pixelbeat.org/programming/gcc/static_assert.html

    0 讨论(0)
  • 2020-12-04 10:20

    How about -Wunused-label ?

    0 讨论(0)
提交回复
热议问题