我在編譯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