C – 如何使用PROGMEM存储和读取char数组

我有三个char数组,我不希望Arduino将它存储在SRAM中 ,所以我想使用PROGMEM来存储和读取flash 。

char *firstArr[]={"option 1","option 2","option 3","option 4"}; char *secondArr[]={"test 1","test 2"}; 

有一个关于如何在Arduino网站上做到这一点的例子。 (参见“字符串数组”。)

是的,Arduino网站上有一个例子。 但我想让你了解GCC中的编译器错误 ,以及以下解决方法:

 /** * Alternative to PROGMEM storage class * * Same effect as PROGMEM storage class, but avoiding erroneous warning by * GCC. * * \see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734 */ #define PROGMEM_ __attribute__((section(".progmem.data")))