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

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

    Solution for GCC not causing conflicts with other compilers

    #ifdef __GNUC__
    #define VARIABLE_IS_NOT_USED __attribute__ ((unused))
    #else
    #define VARIABLE_IS_NOT_USED
    #endif
    
    int VARIABLE_IS_NOT_USED your_variable;
    

提交回复
热议问题