Hi all,
I'm trying to setup a structure array in flash, using __flash but am running into problems getting it to compile :
Code snippet to illustrate the problem.
const char Name8020[] PROGMEM = "8020"; const __flash char Name8021[] = "8021"; const __flash char Name8022[] = "8022"; typedef struct { char *ChipName; // Name of chip uint16_t MaxAddr; // Max rom address } chipmodel_t; const __flash chipmodel_t Mod8020 = { (char *)Name8020, 1024 }; const __flash chipmodel_t Mod8021 = { (char *)Name8021, 1024 }; const __flash chipmodel_t Mod8022 = { (char *)Name8022, 2048 };
I get no errors for Mod8020, which has Name8020 defined the old way with PROGMEM, but Mod8021 complains that it's not constant.
Compiling C: Dump804x.c avr-gcc -c -mmcu=atmega2560 -I. -gdwarf-2 -DF_CPU=16000000UL -DSERIAL_STATUS -DCOOKED_SERIAL -DNOUSART1 -DSTDIOIN -DUSE_HEXDUMP -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./Dump804x.lst -std=gnu99 -MMD -MP -MF .dep/Dump804x.o.d Dump804x.c -o Dump804x.o Dump804x.c:50:1: error: initializer element is not constant const __flash chipmodel_t Mod8021 = { (char *)Name8021, 1024 }; ^ Dump804x.c:50:1: error: (near initialization for 'Mod8021.ChipName') Dump804x.c:51:1: error: initializer element is not constant const __flash chipmodel_t Mod8022 = { (char *)Name8022, 2048 }; ^ Dump804x.c:51:1: error: (near initialization for 'Mod8022.ChipName') make: *** [Dump804x.o] Error 1 > Process Exit Code: 2
I'm obviously doing something wrong but can't figure out what, as the strings are defined const.
Cheers.
Phill.