3

Possible Duplicate:
Unsigned keyword in C++

I'm currently learning about how directly access memory mapped devices (specifically Raspberry Pi GPIO) and in some sample code I see the following:

// I/O access
volatile unsigned *gpio;

What confuses me is no type seems to be defined. Is this valid C++ and if so what does the above code declare?

Thanks!

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

Community
  • 1
  • 1
Ian Dallas
  • 12,451
  • 19
  • 58
  • 82

2 Answers2

4

unsigned alone is the same as unsigned int.

Same as this:

volatile unsigned int *gpio;

Just shorter.

Pubby
  • 51,882
  • 13
  • 139
  • 180
2

An unsigned qualifier with no underlying type is simply shorthand for unsigned int.

The volatile is an indication to the compiler that this value may change in ways that the program doesn't expect. In other words, the compiler shouldn't try to do any caching or optimisation on the value, since it doesn't know how it will change.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953