7
volatile void * ptr; 

Whether ptr is volatile or it points to the volatile location.

So the actual doubt is : Is the same thing applied to the above declaration as it applied with const qualifier ?

Little explanation will help me a lot.

3 Answers 3

8

It's a pointer to volatile data. If the pointer itself should be volatile but not the data it points at, you'd use:

void * volatile ptr; 

So yes, it works the same way as the const modifier.

Sign up to request clarification or add additional context in comments.

2 Comments

oh thnx .. it means the same as const ..We put const before and after the * and the meaning changes right ?
Yes; volatile void * ptr = void volatile * ptr
4

A Microsoft explanation:

The volatile keyword specifies that the value associated with the name that follows can be modified by actions other than those in the user application.

The volatile keyword is useful for declaring objects in shared memory that can be accessed by multiple processes.

1 Comment

As well as memory addresses that represent a piece of hardware, rather than actual memory e.g. the "address" of a serial port, or a DMA'ed HDD or something.
2

Both const and volatile are type qualifiers (they're the only type qualifiers in C, in fact). The syntax for using them is identical.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.