volatile attribute
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
volatile attribute

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System
Author Message
Gianluca Moro
Guest





Posted: Mon Dec 06, 2004 8:44 pm    Post subject: volatile attribute Reply with quote

Hi,

the volatile attribute is an indication that the variable can change
for example on account of an interrupt.

With this indication the compiler cannot use a register to store the variable,
or do any type of optimization.

For example if a volatile variable is not used, the compiler do not
remove it, as it could be used by an interrupt

bye
giammy
Back to top
Mark A. Odell
Guest





Posted: Tue Dec 07, 2004 1:13 am    Post subject: Re: volatile attribute Reply with quote

giangiammy@yahoo.com (Gianluca Moro) wrote in
news:dbacaf5c.0412060744.729db90e@posting.google.com:

Quote:
the volatile attribute is an indication that the variable can change
for example on account of an interrupt.

Volatile is a keyword in C.

Or when you create a pointer to a volatile "thing" that is, in fact,
memory mapped hardware. If the hardware updates the "thing" and the
compiler knows the variable is volatile then things should work as you
expect. This is not a requirement of ISO C which specifies the behavior of
volatile variables in a very restricted way.

Quote:
With this indication the compiler cannot use a register to store the
variable, or do any type of optimization.

No, it can use a register but it must reload the register with the source
location every time you access the volatile variable.

Quote:
For example if a volatile variable is not used, the compiler do not
remove it, as it could be used by an interrupt

That's a consequence of volatile.

--
- Mark ->
--
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB