In one of the C source code files I found the following line (macro):
#define USE(x) (x) = (x)
It is used like this:
int method(Obj *context)
{
USE(context);
return 1;
}
After googling for it, I found the following description:
// Macro to get rid of some compiler warnings
Could you please tell me more about this macro?
Thanks for your answers!
Some compilers complain when variables are never actually used for anything. for instance:
int main(int argc, char **argv) {
return 0;
}
Gives:
Output from llvm C/C++/Fortran front-end (llvm-gcc)
/tmp/webcompile/_7618_1.c: In function 'main':
/tmp/webcompile/_7618_1.c:9: warning: unused parameter 'argc'
/tmp/webcompile/_7618_1.c:9: warning: unused parameter 'argv'
Queerly, I can just get rid of those warnings using your macro:
#define USE(x) (x) = (x)
int main(int argc, char **argv) {
USE(argc); /* get rid of warnings */
USE(argv); /* get rid of warnings */
return 0;
}
The compilers give warnings when a variable is defined/declared but never used. These include function arguments. Some coding styles require to always name function arguments, but some of them may not be used in the function. They are reserved for future use. For these cases you could USE(param)
to avoid the warning
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