tags:

views:

101

answers:

1

I am trying to debug code using gdb, but when I try to watch my variable color it say this

No symbol "color" in current context.

The variable is a int and is clearly in the scope. the code is as follow

int color=0;

if(color==0)
  color=1;

and my debugger is passed the declaration of the variable.

I am only doing, with a break point at the if(color==0)

(gdb) watch color

I might suspect the compiler or something, is that possible?

Edit : there is some issues with debugging in constructors with GDB

A: 

You need to make sure you're passing the -g flag to gcc when you compile your code. You should also pass -O0 to ensure that the compiler isn't optimizing your variable away.

wjt