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.
Try
const char* const menu[] PROGMEM...
Thus the array itself is constant, not a mutable array of const char*
pointers, as it were in the original code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.