Volatile unsigned * in C ++

Possible duplicate:
Unsigned keyword in C ++

I am currently looking into how to access memory mapped devices (specifically the Raspberry Pi GPIO) directly and in some example code . I see the following

// I/O access
volatile unsigned *gpio;

      

What confuses me is the type is undefined. Is this valid C ++, and if so, what does the above code declare?

Thank!

PS: I know about the Raspberry Pi StackExchange, but this question is related to C ++ syntax only.

+3


source to share


2 answers


unsigned

is the same as unsigned int

.

The same as:



volatile unsigned int *gpio;

      

Just shorter.

+4


source


An attribute unsigned

with no base type is just shorthand for unsigned int

.



volatile

is an indication to the compiler that this value can change in ways that the program does not expect. In other words, the compiler shouldn't try to do any caching or optimization by value, since it doesn't know how it will change.

+2


source







All Articles