Yann Ramin wrote:
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.
Oh, sorry! So what is your real code?
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.
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users