我在编译gcc 4.6.1
中的C源代码时收到以下警告。警告:变量集但未使用[-Wunused-but-set-variable]
warning: variable set but not used [-Wunused-but-set-variable]
我refered这个链接Wunused但是能拿到底是什么原因造成这种warning.Would有人告诉我在更多的细节是什么原因造成这样的警告,以及如何才能摆脱它?
[编辑] 我有以下的代码片段。编译显示上述警告。你能否建议我如何纠正它?
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.
// }
但我* *使用它!我不明白为什么我看到这个错误。如果我删除的定义,它抱怨说,我使用的变量没有定义它。如果我包含定义,它说我没有使用它。什么可能会导致此警告? – endolith
@endolith:哦,没关系。我不使用* *它。这意味着我只是将它设置(在多个地方),从来没有测试的价值是什么,因为我没有写那一部分呢。咄。 – endolith