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
  • Examine the preprocessor listing, and ensure that your Macro expansions are actually giving what you intended.
    (The option is on the 'Listings' tab in the uVision Project options, or use the PREPRINT command-line option).

    Unfortunately, Keil C51 does not have the option to retain comments in the preprocessor listing. :-(

    If you're still stuck, post the macro expansions - there's no point in everyone trying to do the preprocessor's donkey-work!

    And please use the &ltpre&gt and &lt/pre&gt tags when posting code - see the 'Tips for Posting Messages' link in the sidebar.

    You could also try looking at the MSVC preprocessor listing, to spot any differences.
    the option is something like /EP, which does retain comments :-)

Reply
  • Examine the preprocessor listing, and ensure that your Macro expansions are actually giving what you intended.
    (The option is on the 'Listings' tab in the uVision Project options, or use the PREPRINT command-line option).

    Unfortunately, Keil C51 does not have the option to retain comments in the preprocessor listing. :-(

    If you're still stuck, post the macro expansions - there's no point in everyone trying to do the preprocessor's donkey-work!

    And please use the &ltpre&gt and &lt/pre&gt tags when posting code - see the 'Tips for Posting Messages' link in the sidebar.

    You could also try looking at the MSVC preprocessor listing, to spot any differences.
    the option is something like /EP, which does retain comments :-)

Children
No data