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

error in keil 7.06 a

1 open project HELLO
2 insert int e,b,c; after main
3 in project devce select extended linker
4 translate
5 debug and see that variable e ?????
what is it?
is it new version?

Parents
  • If you assign a value to a variable and never use the variable anywhere else, what should the compiler do? Should it optimize this out or not?

    To answer the rhetorical question:

    Depends on whether the variable is declared volatile or not. If it's volatile, then there are perhaps side effects from the write -- say if it's a hardware register -- and you need to keep the assignment. If not, optimize away.

    So, if you're bent on keeping the variable e in the program, make sure to do something with it. Printf() it. Use it as a loop counter. Something, just to give it a reason to exist. Or just declare it volatile.

Reply
  • If you assign a value to a variable and never use the variable anywhere else, what should the compiler do? Should it optimize this out or not?

    To answer the rhetorical question:

    Depends on whether the variable is declared volatile or not. If it's volatile, then there are perhaps side effects from the write -- say if it's a hardware register -- and you need to keep the assignment. If not, optimize away.

    So, if you're bent on keeping the variable e in the program, make sure to do something with it. Printf() it. Use it as a loop counter. Something, just to give it a reason to exist. Or just declare it volatile.

Children
No data