Hi,
I have a problem compiling codes on Arduino IDE 1.0.1 running on a Raspberry PI.
I'm getting this error:
variable 'menulabel_items' must be const in order to be put into read-only section by means of 'attribute((progmem))'
The problem is that the variable is already declared as const
const char *menulabel_items[] PROGMEM = {Menu_0_Label,Menu_1_Label};
Does anyone know why I'm getting this error and how to get around it?
Also, forgot to mention that this same library compiles just fine on Windows/MacOSX.
Fixed.
I guess it doesn't like the PROGMEM on the array declaration...
This works:
const char *menulabel_items[] = {Menu_0_Label,Menu_1_Label};
Your data isn't stored in program memory with out 'PROGMEM' though.
char Menu_0_Label[] PROGMEM = "test1";
char Menu_1_Label[] PROGMEM = "test2";
char *menulabel_items[] PROGMEM = {Menu_0_Label,Menu_1_Label};
This works fine in 1.0.4 ( windows ) without const.
Maybe try making the data and pointer const ( menulabel_items ) for non-working version:
const char Menu_0_Label[] PROGMEM = "test1";
const char Menu_1_Label[] PROGMEM = "test2";
const char * const menulabel_items[] PROGMEM = {Menu_0_Label,Menu_1_Label};
Like I mentioned on 2nd post, it compiles fine on Windows and MacOSX.
Your 2nd code you posted is how I had it originally and we've been using that way for well over 2 years.
But I was trying to compile on a linux weezy and was not compiling until I removed the PROGMEM from the pointer array.
So, I my code became:
const char Menu_0_Label[] PROGMEM = "test1";
const char Menu_1_Label[] PROGMEM = "test2";
const char * const menulabel_items[] = {Menu_0_Label,Menu_1_Label};
And that compiles fine now. Technically speaking, even if my pointer array doesn't go into flash, it won't take much ram memory anyway... It's just a pointer array after all, right?
Are you sure that my second code is how you had it, there is a second 'const' in there. You originally posted the line below with only a single const:
const char *menulabel_items[] = {Menu_0_Label,Menu_1_Label};
const char * const menulabel_items[] PROGMEM = {Menu_0_Label,Menu_1_Label};
Oh wow... You are right!!!!
I missed that 2nd const.
Indeed the 2nd const did the trick.
Thanks a lot!!!