This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ERROR 247 "non-address/-constant initializer"

Hi there,

I'm using the C51 compiler version 5.5. I'm trying to use the following construct:

#define SYSPTR_LOCAL_CODE 0x40
#define MM0MNDEF_BANK 0x02

const char Str[] = "STRING";

typedef struct
{
byte bType;
byte bHighO;
byte bLowO;
} MakeSysPtr;

#define MakeSysPtr_I( T, B, O ) { ( T | B ), ((word)O >> 8), ((word)O & 0x0FF) }

typedef struct
{
byte bKeys;
MakeSysPtr sLeft;
} MakeKeyDef_T;

const MakeKeyDef_T KEY_DEF =
{
ALL_SOFT_KEYS,
MakeSysPtr_I( SYSPTR_LOCAL_CODE, MM0MNDEF_BANK, Str )
};
The compiler generates the the error message listed in the summary on the line were we use the MakeSysPtr_I ( initializer for the MakeSysPtr structure ). Could someone point out why we're getting this error. I have no problems compiling this piece of code with Visual C or ARM compilers.

Thanks,
Doru.

Parents
  • You are trying to shift a constant 8 times right (Parameter 'O' of your macro), but the value of the constant is unknown at compile time. In the macro invocation the address of the array "Str" is passed as a parameter. The address of "Str" will be fixed later on by the linker. But the linker cannot modify (in your case shift) data. So this macro cannot be processed by the compiler.

    Try storing the address as a 16-bit-pointer. If want access to the bytes of the pointer, use a union.

    HHK

Reply
  • You are trying to shift a constant 8 times right (Parameter 'O' of your macro), but the value of the constant is unknown at compile time. In the macro invocation the address of the array "Str" is passed as a parameter. The address of "Str" will be fixed later on by the linker. But the linker cannot modify (in your case shift) data. So this macro cannot be processed by the compiler.

    Try storing the address as a 16-bit-pointer. If want access to the bytes of the pointer, use a union.

    HHK

Children