我使用AVR-GCC 4.7.0版和字符串數組,當我試圖創建FLASH存儲器字符串數組我得到的錯誤:存儲在閃存與PROGMEM在Arduino的
variable ‘menu’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’
我使用此代碼:
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};
我已經看過堆棧溢出問題C - how to use PROGMEM to store and read char array,但我看到的答案不包括const
關鍵字這使我相信這是需要之前,他們寫的。
如何解決這個問題?
const char * const menu[] PROGMEM = {menu0, menu1, menu2, menu3, menu4, menu5};
他回答。
試試這個:'const char * const menu [] ...' – imreal