我使用的是AVR版本4.7.0,当我试图在闪存中创建一个字符串数组时,我会得到以下错误:
要通过‘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};我已经阅读了堆栈溢出问题https://stackoverflow.com/questions/13093927/c-how-to-use-progmem-to-store-and-read-char-array,但是我看到的所有答案都没有包含const关键字,这让我相信它们是在需要之前编写的。
如何解决这个问题?
const char * const menu[] PROGMEM = {menu0, menu1, menu2, menu3, menu4, menu5};是答案。
发布于 2013-01-14 19:48:00
试一试
const char* const menu[] PROGMEM...因此,数组本身是常量的,而不是const char*指针的可变数组,就像原始代码中的那样。
https://stackoverflow.com/questions/14325485
复制相似问题