Quantcast
Channel: Are volatile reads and writes atomic on Windows+VisualC? - Stack Overflow
Viewing all articles
Browse latest Browse all 6

Answer by Maxim Egorushkin for Are volatile reads and writes atomic on Windows+VisualC?

$
0
0

A bit off-topic, but let's have a go anyway.

... there are the docs for The Interlocked* functions, especially InterlockedExchange which takes a volatile(!) variable ...

If you think about this:

void foo(int volatile*);

Does it say:

  • the argument must be a pointer to a volatile int, or
  • the argument may as well be a pointer to a volatile int?

The latter is the correct answer, since the function can be passed both pointers to volatile and non-volatile int's.

Hence, the fact that InterlockedExchangeX() has its argument volatile-qualified does not imply that it must operate on volatile integers only.


Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>