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

前端 未结 8 1043
栀梦
栀梦 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:12

    Wrap this functions by the following directives All the code that will be placed between push and pop will not warn you about unused functions. All the rest of the code (outside push and pop) will not be affected.

    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Wunused-function"
    
    ... your code
    
    #pragma GCC diagnostic pop
    

提交回复
热议问题