Keil Logo

µVISION DEBUGGER: Local Variables Not Displayed


Information in this article applies to:

  • C51 any Version
  • C251 any Version
  • C166 any Version

QUESTION

I have a function foo which is written as follows:

void foo(void)
{
  unsigned char bar;
  bar = 4;
}

When I step through this function in the debugger, the variable bar is not displayed in the locals window. Is this a bug?

ANSWER

No. The optimizer removed the variable bar since you do not do anything with it. It is initialized but left unused, so all code related to the variable is removed.

You can either

  • Do something with the variable.
  • Declare the variable as volatile, which stops the compiler from optimizing code related to the variable out. For example:
    volatile unsigned char bar;
    

SEE ALSO

Last Reviewed: Tuesday, December 8, 2020


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.