我的代码中有下一行:
const int xxx = hhh.IR(); // line 234
if( !aaaaaaa[iT][xxx] ) // line 235
编译器抱怨:
/FILE.cxx:234:21: warning: unused variable 'xxx' [-Wunused-variable]
/FILE.cxx:235:30: error: 'xxx' was not declared in this scope
(它在取笑我吗?)这怎么可能?
我检查过两个xxx
使用相同的字符,只需复制一个xxx
并替换其他字符。
P.S .: 我有
答案 0 :(得分:7)
当第一行和第二行的范围不同时,这是可能的。
这里是一个会产生错误的代码示例:
if ( y == z )
const int xxx = hhh.IR();
if( !aaaaaaa[iT][xxx] )
等于:
if ( y == z ) {
const int xxx = hhh.IR();
}
if( !aaaaaaa[iT][xxx] )
所以修复是添加大括号:
if ( y == z ) {
const int xxx = hhh.IR();
if( !aaaaaaa[iT][xxx] )