I am trying to preserve a variable so I can see its value while debugging optimized code. Why is the following an illegal constant expression?
void foo(uint_32 x)
{
static uint_32 y = x;
...
}
For your purpose you probably want this:
void foo(uint_32 x)
{
static uint_32 y;
y = x;
...
}
What you tried to do is an initialisation. What is done above is an assignment.
Maybe for your purpose this would be even more interesting:
static uint_32 y;
void foo(uint_32 x)
{
y = x;
...
}
Now the variable y
can easily be accessed by the debugger once the foo
function is finished.