Basher1
- 27
- 0
I have been going through a book on embedded development. I have been followin the C programs in the book with about 95% success as C is not completely new to me. But I am new to pointers so I was hoping someone would kindly clear a few things for me.
#define INPUT (*((volatile unsigned long *)0x40004004))
the hex number 0x40004004 represents the address of an general purpose I/O port for a microcontroller. Now I know that one of the * symbols(I don't know exactly which one, but I am guessing the first one from the left) represents the indirection operator which treats the address as an address and not a literal number. I also know that the volatile unsigned long is used so the compiler knows it needs to read a 32-bit unsigned number from the address. But I don't know why the there is another * in this statement.
another two examples that are leaving me stumped
*(long*)pt = NULL
and
FreePt = (long*)*pt
how do I interpret these?
#define INPUT (*((volatile unsigned long *)0x40004004))
the hex number 0x40004004 represents the address of an general purpose I/O port for a microcontroller. Now I know that one of the * symbols(I don't know exactly which one, but I am guessing the first one from the left) represents the indirection operator which treats the address as an address and not a literal number. I also know that the volatile unsigned long is used so the compiler knows it needs to read a 32-bit unsigned number from the address. But I don't know why the there is another * in this statement.
another two examples that are leaving me stumped
*(long*)pt = NULL
and
FreePt = (long*)*pt
how do I interpret these?