I have been getting following warning while compiling the C source code in the gcc 4.6.1.
warning: variable set but not used [-Wunused-but-set-variable]
I refered to this link Wunused but could get exactly what is causing this warning.Would anybody tell me in more details what is causing this warning and how can We get rid of it?
[EDIT]
I have a following snippet of code. The compile shows the above mentioned warning. Could you please suggest me how can correct it?
test_function(){
BOOL BoolTest;
BoolTest = test_fucntion2();
#ifdef CHECK
if (!BoolTest) {
misc_StartErrorReport();
misc_ErrorReport("\n test_function2: Input not indexed.\n");
misc_FinishErrorReport();
}
#endif
//
BoolTest is no more used below it.
// }
You need to include the preprocessor guards around the declaration and initialisation of
BoolTest:(this assumes that you still want to call
test_function2()even ifCHECKis not defined, presumably for its side-effects – if not, then you don’t need the#elsesection and you can combine the two#ifdefblocks into one).