I’ve found this snippet on a website :
#define DISPLAY_CR (*(volatile unsigned int *) 0x4000000)
DISPLAY_CR = somevalue;
that is supposed to describe DISPLAY_CR as a volatile unsigned int pointer to the adress 0x4000000
What I don’t understand is why :
- the double parenthesis imbrication ?
- the two stars using (why two stars and not only one ?)
The extra parentheses are standard practice in macros. Macros are expanded in copy-and-paste fashion, so without the parentheses, the precedence may be altered depending on the context.
Ignoring the extra parentheses, your code expands to:
which is equivalent to:
which hopefully should be clearer.