what does this macro mean ? I just find the following macro in source files:
#define UNUSED(x) ((x)=(x))
It is probably there to suppress compiler warnings of unused variables/arguments to functions. You could also use this:
// C++ only
void some_func(int /*x*/)
Or
// C and C++
void some_func(int x)
{
(void)x;
}
Or your compiler may support a flag to do so, but these are portable and won't skip over valid warnings.
Use it to get rid of any compiler warning referring an unused variable.
Some compilers issue a warning about unused variables - variables that are defined but never referenced. Sometimes you have code that references a variable only under some conditional ifdefs (only on some platforms or only in debug) and it is inconvenient to duplicate those conditions at the point the variable is defined. A macro like this can be used to suppress the unused variable warning in such cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With