> > Did you tell your compiler to compile C++ code? In C you cannot > declare/define new local variables inside a block after the first > instructions (you have to omit the preceding line count = count << 3;). > -> This is a syntactical error!
This is a copy & paste error. And yes, count is undefined. Doesn't really matter in this case. I don't care what the value of count is in this example. > A possible reason for the difference with or without volatile is the > optimization: > The assignment of t is the last executed line of code. t is not used and > can be optimized away and so can the last line. As a next step you can > see that if you omit the last line g is not used anywhere else and thus > can be optimized away. (Finally for the same reason also count can be > omitted and main() is ... empty). > The situation differs if you plan to access t from out of main's control > flow (i.e. from an ISR). In this case all the other lines are needed > too. You use volatile to inform the compiler about this very fact. Thats exactly why I'm trying to use volatile. And the compilation suceeds with -O0 without voltaile, which should prevent any dead stripping of code.
