nachus001
Junior Member level 2
iccavr initializer must be constant
Hi all:
My questions is on how to retrieve an address from an item stored in eeprom.
I´m currently using the ICC AVR which works very well, but I have some errors trying do whith this example:
//chipset AT90S2313
.
.
.
.
#pragma data: eeprom // switch to eeprom area and reserve some data
//space
char foo[20]; //array 1
char man[10]; //array 2
char bar[5]; //array 3
#pragma data:data // switch back to SRAM
.
.
.
const char sizes_ee[] = {sizeof foo, sizeof man, sizeof bar}; //const table
// with the sizes of data
// here comes the problems when trying to retrieve addresses
const char bases_ee[] = {&foo[0], &man[0], &bar[0]};
Well, the compiler complains all sort of things(mainly "initializer must be constant") when compiling this last line. I´dont know how to fix this.
I know "&" is a run time direction operator, but I´ve seen that it can be interpreted as a "compiling time" operator (assigning the correct data to a const array, in this case)
Can anyone here help me?
Modifications and casts like
const char bases_ee[] = {(char)&foo[0], (char)&man[0], (char)&bar[0]};
make things worse (the compiler complains harder)
Thxs in advance
Nachus
Hi all:
My questions is on how to retrieve an address from an item stored in eeprom.
I´m currently using the ICC AVR which works very well, but I have some errors trying do whith this example:
//chipset AT90S2313
.
.
.
.
#pragma data: eeprom // switch to eeprom area and reserve some data
//space
char foo[20]; //array 1
char man[10]; //array 2
char bar[5]; //array 3
#pragma data:data // switch back to SRAM
.
.
.
const char sizes_ee[] = {sizeof foo, sizeof man, sizeof bar}; //const table
// with the sizes of data
// here comes the problems when trying to retrieve addresses
const char bases_ee[] = {&foo[0], &man[0], &bar[0]};
Well, the compiler complains all sort of things(mainly "initializer must be constant") when compiling this last line. I´dont know how to fix this.
I know "&" is a run time direction operator, but I´ve seen that it can be interpreted as a "compiling time" operator (assigning the correct data to a const array, in this case)
Can anyone here help me?
Modifications and casts like
const char bases_ee[] = {(char)&foo[0], (char)&man[0], (char)&bar[0]};
make things worse (the compiler complains harder)
Thxs in advance
Nachus