pointers - The meaning of "asterisk type asterisk" in C : *(volatile int *) foo -
i have tried looking around not able find answer this. found explaining when use double asterisk, **, however, not sure whether applied case.
i have come across embedded systems code looks bit foreign me :
port0 = *(volatile int *)(0x1c002100)
what operation doing reads gpio port address 0x1c002100
. deal asterisks ?
i have written :
port0 = *0x1c002100
are doing type of pointer type casting , hence use 2 asterisks ? best guess. thank !
look @ expression, first convert integer constant pointer, deference pointer, yield integer. same as:
int *p = (volatile int *)(0x1c002100); int n = *p; port0 = n;
the first *
denotes pointer type, second dereference operator.
however second line invalid c code, since cannot dereference integer.
port0 = *0x1c002100;
Comments
Post a Comment