This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

char variables not initializing correctly

I have a function in which I declare two variables as follows:

unsigned char voltage = 0;
unsigned char test = 0;

When I run the code in the debugger, these variables are initialized to random numbers. What is the problem?

Parents
  • Beware of the optimiser.

    Does the problem go away when you turn down the level of optimisation? The optimiser can do things that the debugger is not entirely aware of and, therefore, seems to give strange results.

    Of course, your algorithm should still work correctly, optimisation should not change that.

Reply
  • Beware of the optimiser.

    Does the problem go away when you turn down the level of optimisation? The optimiser can do things that the debugger is not entirely aware of and, therefore, seems to give strange results.

    Of course, your algorithm should still work correctly, optimisation should not change that.

Children