I encounter the strangest behavior in VS 2012 (I'm writing in cpp).
I click "add watch" on a variable and it says "identifier is undefined".
Here's an example of the code:
for (int j=0;j<32;j++)
{
unsigned char curValue=desc1.at<unsigned char>(0,j);
printf("%s\n",curValue);
}
I had to use printf to show the value of curValue. lol.
Has anyone encountered such behavior?
Edit: more strange this occur. When debugging the following code:
int b1[8];
for (int k=0;k<7;k++)
b1[k]=0;
char q=curValue;
int t=0;
while (q!=0){
b1[t++]=q%2;
q=q/2;
}
The debugger just skips the loop with b1[k]=0;
Please note curValue is undefined even inside the loop.
Thanks!
Select the variable a in the code. Select Debug > QuickWatch, press Shift+F9, or right-click and select QuickWatch.
Right click on the variable in code, and select "Add Watch" Right click on the variable in the "Locals" windows, and select "Add Watch" Type the variable name into a new row in the Watch pane itself.
As Joachim said: curValue is defined inside the loop. If watch window in visual studio see it as undefined value then you should turn off Compiler optimization.
Compiler optimization default is /O2 optimize for speed. To turn it off :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With