Hi !
I have the following code, which I am using in an Embedded systems,
c-compiler.. However I see the same problem with GCC too..
I need the last 10 bits of an address pointer, which is completly know
at link time, but will be symbols at the compile time. I used the
following code for this initalization..
uint32 data_ptr_mask = ((uint32) data) & 0x3ff;
for illustration purpose, I have also included
uint32 data_ptr_off = ((uint32 ) data) +0x3ff;
When I compile this code (see the example routine below) I get the
following error with gcc
"error: expression must have a constant value"
Can somebody tell me why the bit operators, "*" and "/" don't work
while "+" and "-" do.
TIA
-P.B. Srinivas
/****** Start of CODE ***/
#include <stdio.h>
typedef int int32;
typedef unsigned uint32;
/* Global variable declarations **/
int32 data[64];
/** this works **/
uint32 data_ptr = (uint32 ) data;
/** this also works **/
uint32 data_ptr_off = ((uint32 ) data) +0x3ff;
/** this doesn't work , only +/- operators **/
/** seem to work, why is this ? ****/
uint32 data_ptr_mask = ((const uint32) data) & 0x3ff;
int main()
{
printf("Pointer Addition %x %x\n",data_ptr, data_ptr_off);
printf("Pointer Masking %x %x\n",data_ptr, data_ptr_mask);
}
/*********** End of code *************/