I have recently upgraded my Arduino to avr-gcc 4.7.0 (and supporting libraries etc) and need to modify my sketches to suit.
Th Progmem syntax has changed and to get it right I wrote a small test sketch as shown below:
//#include <avr/io.h>
#include <avr/pgmspace.h>
PROGMEM const char MenuItem1[] = "Menu Item 1";
PROGMEM const char MenuItem2[] = "Menu Item 2";
PROGMEM const char MenuItem3[] = "Menu Item 3";
PROGMEM const char* const MenuItemPointers[] = {MenuItem1, MenuItem2, MenuItem3};
void setup(void)
{
char buffer[20];
strcpy_P(buffer, (char*)pgm_read_word(&MenuItemPointers[1]));
}
void loop(void)
{
}
This compiles without errors however I don't understand why it requires the two constant qualifiers rather than just the first one in the line:
PROGMEM const char* const MenuItemPointers[] = {MenuItem1, MenuItem2, MenuItem3};
Can someone enlighten me?