How can I suppress the warning compiler generating unused variables in a C ++ program?
I am using the g ++ compiler
Compile with the -Wno-unused-variable option.
-Wno-unused-variable
See the GCC documentation of warning parameters for more information.
The -Wno-__ options disable the options set by -W__ . Here we turn -Wunused-variable .
-Wno-__
-W__
-Wunused-variable
In addition, you can apply __attribute__((unused)) to a variable (or function, etc.) to suppress this warning in each case. Thanks to Jesse Good for this.
__attribute__((unused))
Put the cast in void:
int unused; (void)unused;
To remove these warnings, I create a macro that can be used throughout my project:
#define UNUSED(x) (void)(x)
Source: https://habr.com/ru/post/922252/More articles:ServiceStack.Redis: Unable to connect: sPort: 0 - servicestackStop make if find -exec returns non-zero - bashz-index doesn't work very well in ipad - htmlIs there any Sublime Text intellisense for HTML when editing Ruby files? - ruby-on-railsDjango: Convert Youtube URL to HTML - djangoIs this a good return type template for designing a Scala API? - scalaC ++ pointers and references require clarification - c ++MVC model not updating - asp.net-mvcHow to correctly display the view of the Trunk puppet collection based on the properties of the javascript model array? - backbone.jsWITSML api library for .Net / C # client applications? - c #All Articles