Currently I am having a very strange error with the preprocessor. I have searched and couldn't find anything relavent and therefore would like to post it here. Below is my sample code
#include <stdio.h>
#define DDR_BASEADDR 0x000000000U + 128*1024*1024
int main()
{
uint32_t* test2 = (uint32_t*) DDR_BASEADDR;
uint32_t whatIsThis = DDR_BASEADDR;
uint32_t* test3 = (uint32_t*) whatIsThis;
printf( "%x %x %x %x\n\r", DDR_BASEADDR, test2, test3, whatIsThis);
return 0;
}
The output of this code should all be 0x8000000
.
However, the outputs are:8000000 20000000 8000000 8000000
.
I believe it is not the datatype that caused this problem, since it also appears even if i change uint32_t* test2 = (uint32_t*) DDR_BASEADDR;
to int32_t* test2 = (int32_t*) DDR_BASEADDR;
I test this both on ARM A9 from the Zedboard and with C++ online compiler and get the same result. Thank you for your time and effort.
Thang Tran