【发布时间】:2022-11-13 04:04:30
【问题描述】:
我正在尝试在我的 Arduino Mega 2560 上实现 FreeRTOS,在此过程中,我遇到了 2 个我不理解的错误。而且不知道怎么修。希望这里有人这样做。第一个错误是missing binary operator before token "long"。
错误指向 FreeRTOSConfig.h 中的以下行:
#define configCPU_CLOCK_HZ ((unsigned long) 16000000)
这是构建的输出:
C:\Projects\src\config\FreeRTOSConfig.h(36,39): error: missing binary operator before token "long"
#define configCPU_CLOCK_HZ ((unsigned long) 16000000)
^
此定义仅在 port.c 中使用,它还有另一个我无法修复的错误。此错误来自自动生成的 makefile。不确定这两个错误是否相关,但如果有人知道如何修复它,最好在此处添加。错误是:
recipe for target 'src/Core/FreeRTOS/port.o' failed
这就是我在 Makefile 中找到的:
src/Core/FreeRTOS/port.o: ../src/Core/FreeRTOS/port.c
@echo Building file: $<
@echo Invoking: AVR/GNU C Compiler : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -x c -DDEBUG -DBOARD=USER_BOARD -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\include" -I"../src/ASF/common/boards/user_board" -I"../src/ASF/common/boards" -I"../src/ASF/mega/utils/preprocessor" -I"../src/ASF/mega/utils" -I"../src/ASF/common/utils" -I"../src" -I"../src/config" -O1 -fdata-sections -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -g3 -Wall -mmcu=atmega2560 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega2560" -c -std=gnu99 -fno-strict-aliasing -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -mrelax -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
【问题讨论】:
-
这条线看起来完全正常。如果没有更广泛的背景,就不可能说任何话。
-
#define configCPU_CLOCK_HZ 16000000UL呢? -
将
-save-temps添加到命令行选项并查看预处理输出(*.i用于 C,*.ii用于 C++,*.s用于汇编)。 -
@datafiddler 你能解释为什么这会起作用,而“unsigned long”不会吗?因为这样它确实可以正确编译
标签: c++ arduino freertos microchip