| |||||
Technical Support Support Resources
Product Information | C166: INCORRECT ADDRESS WHEN INITIALIZING A POINTERInformation in this article applies to:
SYMPTOMSI have written the following code:
#define BASE_ADDR (unsigned char *)0x80000 + 0x01;
unsigned char *x;
void main(void)
{
x = BASE_ADDR;
*x = 0x55;
}
However, when I execute this, x points to the location 0x00001 not 0x80001. Why is it only assigning my offset of 0x01 to the pointer address? CAUSEYour example uses a 16-bit pointer. When you assign an address above 0xFFFF to a 16-bit pointer, the address is truncated to the lower 16 bits. In this case 0x0001. RESOLUTIONYou can do one of two things depending on your application.
MORE INFORMATION
Last Reviewed: Friday, July 15, 2005 | ||||
| |||||