Prev: Reality check: when will the next C++ be real?
Next: Why does std::basic_ios overload the unary negation operator?
From: Pete Becker on 12 Jul 2010 17:52 On 2010-07-12 12:30:21 -0400, Yaser Zhian said: > > I am the first to admit that I am not well-versed in these matters, > but in theory (and in practice as far as I have experienced) you > should be able to use the "volatile" keyword when declaring the > involved variables to signal to the compiler that their values > might change in some other context (e.g. some other thread) and it > should not try to mess around with the order of the statements > involving them. That's not sufficient. The problem is that, while the compiler isn't allowed to reorder two volatile accesses, it doesn't necessarily prevent reording of other instructions around those volatiles. The result will often not be good. -- Pete Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The Standard C++ Library Extensions: a Tutorial and Reference (www.petebecker.com/tr1book) [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |