“常量”修改器我有一个这样的文件:AVR-GCC并未看到PROGMEM
#include <avr/io.h>
#include <avr/pgmspace.h>
const PROGMEM char* str = "Hello UART!\r\n";
我试图用一个Makefile来编译它,这是最后的命令:
avr-gcc -std=gnu99 -mmcu=atmega328p -DF_CPU=16000000UL -I. -Ilib/ -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wno-main -Wno-strict-prototypes -Wno-comment -g2 -Wextra -Wfatal-errors -Wno-unused-but-set-variable -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--relax -Os main.c lib/uart.c --output main.elf
我收到以下错误:
main.c:9:21: error: variable 'str' must be const in order to be put into read-only section by means of '__attribute__((progmem))' const PROGMEM char* str = "Hello UART!\r\n"; ^ compilation terminated due to -Wfatal-errors. Makefile:71: recipe for target 'main.elf' failed make: *** [main.elf] Error 1
这有什么错我的代码?
我试图移动在声明中各个地方的PROGMEM
关键字,没有任何变化。
尝试:为const char海峡[] PROGMEM = “你好!UART \ r \ n”; –