Fix warnings unused but set variable
2 unresolved threads
2 unresolved threads
I fixed all warnings "-Wunused-but-set-variable" by gcc.
I added the attribute "DUNE_UNUSED" to the variables to avoid the warnings.
Merge request reports
Activity
270 272 { 271 273 char buffer[VAR_ARG_BUFLEN]; 272 274 va_list args; 273 int count; 275 DUNE_UNUSED int count; changed this line in version 2 of the diff
"unused" is a bit of a bad attribute name. It means "This attribute, attached to a variable, means that the variable is meant to be possibly unused. GCC does not produce a warning for this variable." (from GCC); note the "possibly" before "unused".
The C++17 attribute has a better name:
[[maybe_unused]]
So it is fine to apply it to variables that are only used in some configurations (like when building without
-DNDEBUG
). Though often one can just create the variable in configurations where it is also used; I find this the better solution.
270 270 { 271 271 char buffer[VAR_ARG_BUFLEN]; 272 272 va_list args; 273 int count; 274 273 275 274 /* initialize args */ 276 275 va_start(args,format); 277 276 #ifndef NDEBUG 277 int count; 278 278 count = vsprintf(buffer,format,args); changed this line in version 3 of the diff
mentioned in commit 958ae1aa
Please register or sign in to reply