cancel
Showing results for 
Search instead for 
Did you mean: 

volatile const ??

greg_t
Associate II
Posted on August 17, 2010 at 07:04

volatile const ??

4 REPLIES 4
domen23
Associate II
Posted on May 17, 2011 at 14:02

So that it is actually re-read every time (think hardware registers).

Posted on May 17, 2011 at 14:02

''What is the purpose to make a constant volatile''

'const' does not actually mean that it's a constant - it just prohibits writes

''if it can not be changed anyways ?''

It cannot be written by the program - but that does not mean that its value will not change!

As already noted, think of a read-only hardware register...

dthedens2
Associate II
Posted on May 17, 2011 at 14:02

There is a good series of articles by Dan Saks about const & volatile.

Posted on May 17, 2011 at 14:02

const

volatile

''The semantics here indicate that the register's value is read-only but not necessarily unchanging.''

http://en.wikipedia.org/wiki/Const-correctness#Volatile-correctness

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..