Search code examples
c++pointersvolatilequalifiers

What is the meaning of void* volatile* in c++


I am looking at the following code:

inline void* interlocked_read_acquire(void* volatile* x);

and am wondering why not just a volatile void* as an argument. In general what is the semantics or definition of a volatile*? I am also making the assumption that you could use the volatile* qualifier with any other type besides void. Is that correct?


Solution

  • Use cdecl or the clockwise spiral rule to decipher C-style declarations :

    void* volatile* x
    
    • declares x as pointer to volatile pointer to void

    which is different from :

    volatile void* x
    
    • declare x as pointer to volatile void