我在MPLAB 5.45下使用AVR GCC编译器v5.4.0。我在avr-as-pre部分中为编译器定义了一个符号。它将以下内容添加到被调用的命令中:
-DF_CPU=32000000UL在代码中,我有这样的一些检查:
#ifndef F_CPU
// do something它确实起到了一些作用。如果找不到符号的话。关于如何用这种方式定义整个项目的符号,我错了吗?
更新
IDE将这种东西称为“定义符号”:

但实际上,它将它们存储为“预处理宏”:
<AVR-AS-PRE>
<property key="announce-version" value="false"/>
<property key="include-paths" value=""/>
<property key="preprocessor-macros" value="F_CPU=32000000UL"/>
<property key="preprocessor-macros-undefined" value=""/>
<property key="suppress-warnings" value="false"/>
</AVR-AS-PRE>不幸的是,它似乎没有将它们传递给编译器:
$ grep -nrw . -e F_CPU
./nbproject/configurations.xml:117: <property key="preprocessor-macros" value="F_CPU=32000000UL"/>发布于 2021-03-29 08:17:34
您必须在avr-gcc > Preprocessing and messages > Defined symbols部分下定义编译器符号:

https://stackoverflow.com/questions/66843041
复制相似问题