Warning in C++ QT creator Linux
-
Hi,
i used function asint fun(int x,int y){
return 0;
}i did not use variable x and y.
but getting warning as
warning: unused parameter 'x' [-Wunused-parameter]i don not want to remove this variable from this function.
please suggest me how to resolve this issue.
Thanks
Shashi -
-
@shashi-prasad hi, friend, welcome.
you can reference
Q_UNUSED
#define UNUSED(x) (void)x; int fun(int x,int y){ UNUSED(x); UNUSED(y); return 0; }
or just said
int fun(int ,int ){ return 0; } `` you can add x,y when you want to use x,y. at any time.
-
Hi,
An alternative to the good solution proposed by @tomasz3dk: comment the name of the parameters.
-
Hi Shashi - prasad,
You are seeing the warning because, you are not using the variable parameter you are just passing value.
If you even print the value of variable with the help of cout or qDebug i hope you will not see the warning.More over it's just a warning, most of the cases we can ignore Warnings.
-
-
- More over it's just a warning, most of the cases we can ignore Warnings.
Thanks for sharing the link and my intention in mention the above words are not to totally ignore the warnings there are cases which can be ignored and which can't be ignored. I was unable to explain perfectly in post any way thanks for correcting my mistake.