Contents
How to avoid warning unused variable?
By default, the compiler does not warn about unused variables. Use -Wunused-variable to enable this warning specifically, or use an encompassing -W value such as -Weverything . The __attribute__((unused)) attribute can be used to warn about most unused variables, but suppress warnings for a specific set of variables.
How to avoid unused variable warning in c++?
- Do not give the variable a name (C++) void foo(int /*bar*/) {
- Tell your compiler using a compiler specific nonstandard mechanism. See individual answers for __attribute__((unused)) , various #pragma s and so on.
- Switch the warning off.
- Add a cast to void.
What does unused variable mean in c++?
You can use __unused to tell the compiler that variable might not be used.
How to mark unused parameters in C + +?
The most basic abstraction macro you’d think of is as follows: … which you could parameterize as: … so that your configure.ac script could determine what the right mechanism to mark a value as unused in your platform is and perform the replacement.
Are there any optional parameters for C + + macros?
So to answer your question: no, those features don’t exist for macros. Your only option is to define multiple macros with different names (or not use macros at all). As a sidenote: In C++ it’s generally considered good practice to move away from macros as much as possible.
Do you think unused parameters should never exist?
You would think that unused parameters should never exist: if the parameter is not necessary as an input, it should not be there in the first place!
Is there a way to detect empty macro arguments?
With greatest respect to Derek Ledbetter, David Sorkovsky, Syphorlate for their answers, together with the ingenious method to detect empty macro arguments by Jens Gustedt at https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ finally I come out with something that incorporates all the tricks, so that the solution