我得到錯誤「可能未初始化本地指針變量‘ptrNames’用」如果我運行此代碼:#ERROR#潛在的未初始化本地指針變量「ptrNames」使用
void processHits (GLint hits, GLuint buffer[]) //Some prints
{
unsigned int i, j;
GLuint names, *ptr, minZ,*ptrNames, numberOfNames;
if (hits == 0)
noSelected = true;
else
noSelected = false;
ptr = (GLuint *) buffer;
minZ = 0xffffffff;
for (i = 0; i < hits; i++) {
names = *ptr;
ptr++;
if (*ptr < minZ) {
numberOfNames = names;
minZ = *ptr;
ptrNames = ptr+2;
}
ptr += names+2;
}
ptr = ptrNames; //Error at this line!
for (j = 0; j < numberOfNames; j++,ptr++) {
if (hits > 0)
LastSelected = *ptr;
}
}
顯示至少*一些*努力。錯誤信息的哪部分你不明白? –
http://stackoverflow.com/questions/10284782/potentially-uninitialized-local-variable-used-why – UpAndAdam