使用 GCC 和 Make 时如何禁用失败警告?
我正在尝试构建与 AVR 微控制器和 avr-ada 一起使用的 GCC,并且我由于我的常规编译器对 AVR 所需的版本过于挑剔,我遇到了障碍。我收到以下警告,这又会导致 GCC 或 Make 报告错误:
gcc -c -g -O2 -gnatpg -gnata -nostdinc -I- -I. -Iada
-I../../gcc/ada ../../gcc/ada/exp_ch5.adb -o ada/exp_ch5.o
exp_ch5.adb:177:16: warning: function "Has_Address_Clause" is not referenced
make[2]: *** [ada/exp_ch5.o] Error 1
make[1]: *** [all-gcc] Error 2
make: *** [all] Error 2
Is there a way to instruct GCC or Make to not failed on warnings?
I'm trying to build GCC for use with an AVR microcontroller and avr-ada, and I've hit a roadblock caused by my regular compiler being too picky about the version I needed for the AVR. I get the following warning, which in turn causes GCC or Make to report an error:
gcc -c -g -O2 -gnatpg -gnata -nostdinc -I- -I. -Iada
-I../../gcc/ada ../../gcc/ada/exp_ch5.adb -o ada/exp_ch5.o
exp_ch5.adb:177:16: warning: function "Has_Address_Clause" is not referenced
make[2]: *** [ada/exp_ch5.o] Error 1
make[1]: *** [all-gcc] Error 2
make: *** [all] Error 2
Is there a way to instruct GCC or Make to not fail on warnings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
尝试使用
make -k
而不仅仅是make
。这将“继续”而不是停止。Try
make -k
instead of justmake
. That will 'continue' rather than stop.作为深入构建系统的替代方法,请尝试设置
-Wno-error
,您应该能够通过环境(或者在配置时,如果使用 GNU 构建系统)来完成此操作。As an alternative to diving into the build system, try setting
-Wno-error
in CFLAGS, which you should be able to do through the environment (or at configure time, if using the GNU build system).这里的触发器是-gnatpg(实际上是-gnatg):这是“GNAT实现模式(用于编译GNAT单元)”。 -gnatp 的意思是“禁止所有检查”。
我不确定 -gnatg 的全部效果,尽管它肯定会导致警告被视为错误 - 就像 -Werror - 至少在构建编译器本身时;我想我记得在构建 RTS 时看到过非致命警告。
一种可能是仅手动编译 exp_ch5.adb,而不使用 -gnatg;您列出的命令是在 gcc/ 发出的,因此
然后备份一级,然后再次“make”。
这是一个交叉编译器,因此您(我希望!)不需要对完整构建的所有三个阶段重复此操作。
The trigger here is the -gnatpg (actually, the -gnatg): this is the "GNAT implementation mode (used for compiling GNAT units)". -gnatp means "suppress all checks".
I'm not sure of the full effect of -gnatg, though it certainly causes warnings to be treated as errors -- like -Werror -- at any rate while building the compiler itself; I think I remember seeing non-fatal warnings while building the RTS.
One possibility would be to compile just exp_ch5.adb by hand without -gnatg; the command you list was issued at gcc/, so
Then back up one level, and 'make' again.
This is a cross-compiler, so you won't (I hope!) need to repeat this for all three stages of a full build.
似乎 -Werror 标志设置在生成文件。也许您可以在 Makefile 中查找 CFLAGS 选项并删除 -Werror 标志。 Werror 标志将使所有警告变成错误。
It seems the -Werror flag is set in the Makefile. Maybe you can look for the CFLAGS options in the Makefile and remove the -Werror flag. The Werror flag will make all warnings into errors.
一般来说,忽略编译器发出的警告并不是一个好主意。但是,如果这是较大 make 过程的一部分,则可能会在序列的前面插入一个
-Werror
标志。从寻找那个开始。环顾四周,似乎有很多标志可以在编译 Ada 代码时控制警告。例如,
-gnatwF
将根据 本指南。也许您需要的开关可以在此处提供的列表中找到。In general, it is not a good idea to ignore warnings from your compiler. However, if this is a portion of a larger make process there is likely a
-Werror
flag inserted earlier in the sequence. Start by looking for that.After looking around, there seems to be a wealth of flags to control warnings while compiling Ada code. For instance,
-gnatwF
will Suppress warnings on unreferenced formals according to this guide. Possibly the switch you require can be found in the list provided there.在 gcc 配置中,您可以添加
--disable-werror
。不过建议先寻找合适的补丁。
In gcc configure you can add
--disable-werror
.Though it's advisable to seek out a proper patch first.
将“pragma warnings(off, "...")”放入代码的违规部分。
请参阅 http://www.adacore.com/2007/11/ 19/ada-gem-18/。
Put "pragma warnings(off, "...")" into the offending parts of your code.
See http://www.adacore.com/2007/11/19/ada-gem-18/.