What are the consequences of ignoring: warning: unused parameter

前端 未结 8 856
闹比i
闹比i 2020-12-29 23:48

I am working on a C++ project and I noticed that we have a number of warnings about unused parameters.

What effect could it have if these warnings are ignored?

8条回答
  •  渐次进展
    2020-12-30 00:23

    For a gcc specific way to disable the warning, you can use __attribute__((unused)) like

    void foo(int a, int b __attribute__((unused))) {
    
    }
    

    To ignore the second parameter. If your program relies on GCC technologies already, you can use that attribute to be 100% safe from that kind of warning.

提交回复
热议问题