我正在开发Firebird 5模块。它有Atmega2560,我试图编译此代码并得到此警告。
(base) pawansrinivas@Pawans-MacBook-Air Experiment-3 % mkdir -p build
(base) pawansrinivas@Pawans-MacBook-Air Experiment-3 % avr-gcc -g -Wall -O0 -mmcu=atmega328p -c Experiment-3.c -o build/Experiment-3.o
In file included from Experiment-3.c:25:
/opt/homebrew/Cellar/avr-gcc@9/9.3.0_3/avr/include/util/delay.h:112:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" [-Wcpp]
112 | # warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"
| ^~~~~~~
(base) pawansrinivas@Pawans-MacBook-Air Experiment-3 %
字符串
3条答案
按热度按时间dfuffjeb1#
您可能正在使用AVRGCC和avr-libc?
请参阅<util/delay.h>
为了使这些函数按预期工作,必须启用编译器优化,并且延迟时间必须是在编译时为已知常量的表达式。如果不满足这些要求,则导致的延迟将更长(基本上不可预测),而不使用浮点计算的应用程序将经历严重的代码膨胀,链接到应用程序的点库例程。
w8ntj3qf2#
=在嵌入式系统中,如果您使用AVR,则使用交叉目标编译器编译器“
AVR-GCC Toolchain
“因此,如果你想使用延迟函数,你将包括
<avr/delay.h>
,因为你使用AVR处理器家族编译器。我希望我的叔叔能帮助你。
cbeh67ev3#
您需要在编译器中启用优化,即使用标志
-O1
或更高的标志调用avr-gcc
,以使util/delay.h
函数正确工作(并使警告消失)。例如:
字符串
more on different optimization levels in GCC