Home:ALL Converter>An array of strings stored in flash with PROGMEM in Arduino

An array of strings stored in flash with PROGMEM in Arduino

Ask Time:2013-01-15T03:45:56         Author:Favil Orbedios

Json Formatter

I am using AVR-GCC version 4.7.0, and when I attempt to create an array of strings in FLASH memory I get the error:

variable ‘menu’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’

I am using this code:

const char menu0[] PROGMEM = "choice0";
const char menu1[] PROGMEM = "choice1";
const char menu2[] PROGMEM = "choice2";
const char menu3[] PROGMEM = "choice3";
const char menu4[] PROGMEM = "choice4";
const char menu5[] PROGMEM = "choice5";

const char *menu[] PROGMEM = {menu0, menu1, menu2, menu3, menu4, menu5};

I have already read Stack Overflow question C - how to use PROGMEM to store and read char array, but all the answers I see don't include the const keyword which makes me believe that they were written before it was needed.

How does one fix this problem?


const char * const menu[] PROGMEM = {menu0, menu1, menu2, menu3, menu4, menu5};

was the answer.

Author:Favil Orbedios,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/14325485/an-array-of-strings-stored-in-flash-with-progmem-in-arduino
yy