Compilation 编译此示例Teensy源文件

Compilation 编译此示例Teensy源文件,compilation,arduino,microcontroller,Compilation,Arduino,Microcontroller,我似乎无法编译2.0版的blinky.c程序。以下是错误: avr-gcc -c -mmcu=atmega32u4 -I. -gdwarf-2 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./blinky.lst -std=gnu99

我似乎无法编译2.0版的
blinky.c
程序。以下是错误:

avr-gcc -c -mmcu=atmega32u4         -I. -gdwarf-2 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./blinky.lst  -std=gnu99 -MMD -MP -MF .dep/blinky.o.d blinky.c -o blinky.o
blinky.c: In function 'main':
blinky.c:69:12: error: variable '__c' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
blinky.c:72:11: error: variable '__c' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
blinky.c: In function 'morse_character':
blinky.c:83:3: error: variable '__c' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
blinky.c:88:3: error: variable '__c' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
blinky.c:90:3: error: variable '__c' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
blinky.c:93:2: error: variable '__c' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
blinky.c:100:4: error: variable '__c' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
blinky.c:103:4: error: variable '__c' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
blinky.c:110:2: error: variable '__c' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
blinky.c: In function 'morse_P':
blinky.c:125:2: error: variable '__c' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
make: *** [blinky.o] Error 1

我想变量“c”必须是常量。:)这应该是示例代码。。。所以我相信它是有效的。我只是不知道我做错了什么。我想说点好笑的,但同时,错误信息很清楚:您试图将读/写变量强制到只读部分,这让编译器不高兴。有可能示例代码是为一个不太复杂的编译器编写的,而没有为新的编译器进行更新。也可能有一个编译器开关会停止错误(尽管它可能在
生成文件中)。我只想修改代码,不管是不是示例。@user988566-vhallac是对的,progmem()变量必须定义为常量。示例代码错误。示例代码已更新,有点像
blinky.c
可以立即正确编译,因为所有
PROGMEM
变量都已更新为
const
,但是
usb\u debug\u仅限.c仍然需要编辑才能正确编译。