Hi,

maybe it's not always a must but i have diversified some IAR-projects to
mspgcc and found out that the reason of some errors was that several variables were not declared volatile.
Now these projects can be compiled with IAR or mspgcc and do work as
expected and independent of the compiler.

Rolf


Chris Liechti schrieb:
nobo...@web.de wrote:

yes, you should use something like a mutex but if you modify a global
variable in a ISR that variable must be volatile. Most commercial


it's not a "must" in many cases. on function entry, all variables are loaded from RAM anyway (except for functions that are inlined). so, if you don't need to detect changes on the varaible within a loop, you can often get away without volatile. but as Rolf points out, declaring a variable as volatile (that is used from ints and main) is a good idea and you're on the safe side.

compilers like the ones from IAR do handle every variable as volatile but gcc does not. ANSI allows both versions.
Without volatile the code is less portable.

Rolf




-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users



Reply via email to