如果我运行以下代码,我会收到错误“可能使用了未初始化的本地指针变量'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;
}
}