[cfe-users] warning/error issues

Eric Levy contact at ericlevy.name
Fri Oct 11 18:34:56 PDT 2013


Hello,

I began to experiment with clang to build an existing C++ (Qt-based) 
project.  I wanted to make warnings into errors in order to ensure that 
the code is solid.  However, there are several issues:

1) Clang is said to be designed to have the same command-line interface 
as gcc, but the options for warnings and errors are different.  The gcc 
command -Wall is -Werror in clang, and so on.

2) The user documentation states that specific warnings can be made into 
errors or not errors by using the -Werror=foo and -Wno-error=foo 
options.  However, no list of accepted values for foo is given.

3) Finally, gcc/clang both warn on unused variables and parameters. 
This often undesired, especially in C++ where, due to polymorphism some 
implementations of a method may not need certain parameters.  When clang 
produces an error for unused parameters (-Werror enabled), it reports 
the reason is -Wunused-parameter.  However, introducing 
-Wno-error=unused-parameter has no effect, despite documentation to the 
contrary.  The gcc-style -Wno-unused-parameter is equally ineffective. 
So too is replacing unused-parameter with simply unused, which, at least 
according to gcc documentation, subsumes unused variables and parameters 
alike.

Whether these observations represent choice or oversight, I would like 
to know how to make all warnings errors except for unused variables and 
parameters.

Thank you.

Sincerely,
Eric Levy



More information about the cfe-users mailing list