-
volatile int address ??
if i write to macro "SELECT" is it so i am writing to the perticular address as shown below ??
Can sombody explain what "Volatile" supports here.
whether typecast should be int or long ?
--------------------------------
Code:
#define SELECT (*( volatile Unsigned int* )(0x106000 ))
or
#define SELECT (*( volatile unsigned long* )(0x106000 ))
--------------------------------
which is correct ??
---------------------------------
int is 2 bytes
Long is 4 bytes
-
volatile tell the compiler that the value of the pointer variable will change some where else in the code
-
I think wording it like that is too ambiguous. The volatile keyword simply tells the compiler that the it may change at any time.
An example being: when polling a memory mapped address, you may access the same address constant over and over in a loop, generally the compiler would optimize the access out of the loop, but with volatile it knows the value may change at any time from some source.
That address is often for paging stuff, what are you using it for? Chances are a long is the same size as an int on your computer, but that's assuming your on an x86.