What's the meaning of marking a whole class volatile?
Solved
C++ Gurus
-
Hi
Its kinda compiler dependant and also change a bit with c++ 11. ( to mean hardware access related)
Basically it tells the compiler it should not include the class/type in certain optimizations and
caching strategies.
That said, in 30 years of programming I have never used or seen a
volatile class in production code.
Only in cases with a misunderstanding of the keyword and used in inter-thread communication. -
yeah, I tend to think of volatile as a modifier for variables and not classes. Often ask in interviews whether the candidate knows what its for in embedded systems. Often misused, but important to understand the implications and when they are desirable: memory mapped register manipulation, etc.