L
LBJ
I have the following C code:
//pHeadLoc contains an address that can be modified externally,
//therefore it is a volatile pointer to a pointer
volatile int** const pHeadLoc = (int**)0x456000;
int* getHeadPtr()
{
return *pHeadLoc;
}
int readHeadPtr()
{
const int* pHeadPtr;
pHeadPtr = getHeadPtr();
return *pHeadPtr;
}
pHeadLoc is a pointer to a pointer to the head of an array.
pHeadLoc will always be constant, but *pHeadLoc can change without the
CPU's knowledge, as can the rest of the contents of said array. when
readHeadPtr() executes the pHeadPtr = getHeadPtr(); statement, I am
pretty sure that i will be getting valid, up-to-date value since
pHeadLoc is volatile. But when I go to access the data in pHeadPtr, I
am not sure that will be getting valid, up-to-date data since pHeadPtr
is not declared volatile. Does anybody know how this will behave?
email me at (e-mail address removed).
//pHeadLoc contains an address that can be modified externally,
//therefore it is a volatile pointer to a pointer
volatile int** const pHeadLoc = (int**)0x456000;
int* getHeadPtr()
{
return *pHeadLoc;
}
int readHeadPtr()
{
const int* pHeadPtr;
pHeadPtr = getHeadPtr();
return *pHeadPtr;
}
pHeadLoc is a pointer to a pointer to the head of an array.
pHeadLoc will always be constant, but *pHeadLoc can change without the
CPU's knowledge, as can the rest of the contents of said array. when
readHeadPtr() executes the pHeadPtr = getHeadPtr(); statement, I am
pretty sure that i will be getting valid, up-to-date value since
pHeadLoc is volatile. But when I go to access the data in pHeadPtr, I
am not sure that will be getting valid, up-to-date data since pHeadPtr
is not declared volatile. Does anybody know how this will behave?
email me at (e-mail address removed).