Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I don't understand why pointer used in cast

Tags:

c

I do understand that this statement is casting a unsigned volatile char to a memory address but what I don't understand is the pointer after volatile.

#define PORTC *(unsigned char volatile *)(0x1003)
like image 567
Patrick Glenn Avatar asked Sep 10 '13 23:09

Patrick Glenn


1 Answers

It says: treat the number 0x1003 as a volatile unsigned character pointer; read or write the (byte) value at that address, depending on how it is used:

unsigned char c = PORTC;   // read
PORTC = c + 1;             // write
like image 113
Jonathan Leffler Avatar answered Sep 21 '22 04:09

Jonathan Leffler