Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re: Volatile modifier

2012-04-18 by Robert Adsett

On 4/18/2012 5:18 PM, bayramdavies wrote:
> I am still grappling with my "definitive" description of volatile,
> which I hope to submit for review, but there is also work to do for
> which I actually hope to get paid, so it's not ready yet.

How about

-----
volatile controls access to a variable.  Reads and writes to a volatile 
variable must be performed by the compiler in the order written and 
exactly as many times as written.
-----

I think that's accurate, complete and deceptively simple.  All our other 
understandings of its use come from that definition.  A formal 
definition would include more formal definitions but this is a little 
simpler to read if not quite as accurate. It does ignore sequence points 
and reordering within an expression, but if you are concerned about the 
latter you are probably making your code too complex.

Note that this means that

const volatile int *f;

is not only syntactically correct but useful.  And yes, I have used it.

Robert

Oh my found an on-line version of cdecl http://cdecl.org/

Try

explain const volatile int *f

if you have trouble parsing the above declaration


-- 
  From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time?  37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live....
we currently have stock."

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.