Grant Edwards wrote:
On 2010-05-20, Paul F. Sehorne<[email protected]>  wrote:
I'm portiing the TI Chronos Sports Watch firmware from IAR.  Why would
mspgcc complain "error: invalid initializer"

[code]
// In smpl_config.h (changed smpl_config.dat to a header file)
#define THIS_DEVICE_ADDRESS  "{0x79, 0x56, 0x34, 0x12}"

// In nwk_types.h
typedef struct
{
    uint8_t  addr[NET_ADDR_SIZE];
} addr_t;


// In nwk_globals.c
static const addr_t   sMyROMAddress = THIS_DEVICE_ADDRESS;  // compiler
complains "nwk_globals.c:60: error: invalid initializer"
[/code]
That's because your initializer is a string, and addr_t isn't a
string. It's a structure.

Yes.
And I don't know enough about IAR but it looks like the .dat file would be used on the command line.
 For IAR:
-DTHIS_DEVICE_ADDRESS="{0x97, 0x56, 0x34, 0x12}" works

For gcc:
-DTHIS_DEVICE_ADDRESS="{{0x97, 0x56, 0x34, 0x12}}" works

As a define::
#define THIS_DEVICE_ADDRESS {{0x97, 0x56, 0x34, 0x12}}

to initialize the structure.

Best, Dan.


Reply via email to