gcc,make:如何禁用警告失败?

时间:2021-10-11 06:59:31

I'm trying to build gcc for use with an AVR micro controller 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 the gcc or make to report an error:

我正在尝试使用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 fail on warnings?

有没有办法指示gcc或使警告不失败?

7 个解决方案

#1


5  

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".

这里的触发器是-gnatpg(实际上是-gnatg):这是“GNAT实现模式(用于编译GNAT单元)”。 -gnatp表示“禁止所有检查”。

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.

我不确定-gnatg的全部效果,虽然它确实会导致警告被视为错误 - 比如-Werror - 在构建编译器本身时无论如何也是如此;我想我记得在构建RTS时看到非致命警告。

One possibility would be to compile just exp_ch5.adb by hand without -gnatg; the command you list was issued at gcc/, so

一种可能性是在没有-gnatg的情况下手工编译exp_ch5.adb;你列出的命令是在gcc /发出的,所以

$ cd gcc
$ gcc -c -g -O2 -gnatp -gnata -nostdinc -I- -I. -Iada -I../../gcc/ada \
  ../../gcc/ada/exp_ch5.adb -o ada/exp_ch5.o

Then back up one level, and 'make' again.

然后备份一个级别,再次'make'。

This is a cross-compiler, so you won't (I hope!) need to repeat this for all three stages of a full build.

这是一个交叉编译器,所以你不会(我希望!)需要在完整构建的所有三个阶段重复这个。

#2


35  

Try make -k instead of just make. That will 'continue' rather than stop.

尝试make -k而不仅仅是make。这将“继续”而不是停止。

#3


10  

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).

作为潜入构建系统的替代方法,尝试在CFLAGS中设置-Wno-error,您应该能够通过环境(或在配置时,如果使用GNU构建系统)进行设置。

#4


4  

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.

通常,忽略编译器的警告不是一个好主意。但是,如果这是较大make过程的一部分,则序列中可能会先插入-Werror标志。从寻找它开始。

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.

环顾四周后,在编译Ada代码时似乎有大量的标志来控制警告。例如,根据本指南,-gnatwF将根据未引用的正式文件禁止警告。可能您需要的开关可以在那里提供的列表中找到。

#5


3  

It seems -Werror flag is set in Makefile. Maybe you can look for CFLAGS options in Makefile and remove the -Werror flag. The Werror flag will make all warnings into errors.

似乎-Werror标志在Makefile中设置。也许您可以在Makefile中查找CFLAGS选项并删除-Werror标志。 Werror标志会使所有警告都出错。

#6


2  

In gcc configure you can add --disable-werror.

在gcc配置中,您可以添加--disable-werror。

Though it's advisable to seek out a proper patch first.

虽然建议先找一个合适的补丁。

#7


0  

How about putting "pragma warnings(off, "...")" into the offending parts of your code?

如何将“pragma warnings(off,”......“)”放入代码的违规部分?

See http://www.adacore.com/2007/11/19/ada-gem-18/.

#1


5  

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".

这里的触发器是-gnatpg(实际上是-gnatg):这是“GNAT实现模式(用于编译GNAT单元)”。 -gnatp表示“禁止所有检查”。

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.

我不确定-gnatg的全部效果,虽然它确实会导致警告被视为错误 - 比如-Werror - 在构建编译器本身时无论如何也是如此;我想我记得在构建RTS时看到非致命警告。

One possibility would be to compile just exp_ch5.adb by hand without -gnatg; the command you list was issued at gcc/, so

一种可能性是在没有-gnatg的情况下手工编译exp_ch5.adb;你列出的命令是在gcc /发出的,所以

$ cd gcc
$ gcc -c -g -O2 -gnatp -gnata -nostdinc -I- -I. -Iada -I../../gcc/ada \
  ../../gcc/ada/exp_ch5.adb -o ada/exp_ch5.o

Then back up one level, and 'make' again.

然后备份一个级别,再次'make'。

This is a cross-compiler, so you won't (I hope!) need to repeat this for all three stages of a full build.

这是一个交叉编译器,所以你不会(我希望!)需要在完整构建的所有三个阶段重复这个。

#2


35  

Try make -k instead of just make. That will 'continue' rather than stop.

尝试make -k而不仅仅是make。这将“继续”而不是停止。

#3


10  

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).

作为潜入构建系统的替代方法,尝试在CFLAGS中设置-Wno-error,您应该能够通过环境(或在配置时,如果使用GNU构建系统)进行设置。

#4


4  

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.

通常,忽略编译器的警告不是一个好主意。但是,如果这是较大make过程的一部分,则序列中可能会先插入-Werror标志。从寻找它开始。

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.

环顾四周后,在编译Ada代码时似乎有大量的标志来控制警告。例如,根据本指南,-gnatwF将根据未引用的正式文件禁止警告。可能您需要的开关可以在那里提供的列表中找到。

#5


3  

It seems -Werror flag is set in Makefile. Maybe you can look for CFLAGS options in Makefile and remove the -Werror flag. The Werror flag will make all warnings into errors.

似乎-Werror标志在Makefile中设置。也许您可以在Makefile中查找CFLAGS选项并删除-Werror标志。 Werror标志会使所有警告都出错。

#6


2  

In gcc configure you can add --disable-werror.

在gcc配置中,您可以添加--disable-werror。

Though it's advisable to seek out a proper patch first.

虽然建议先找一个合适的补丁。

#7


0  

How about putting "pragma warnings(off, "...")" into the offending parts of your code?

如何将“pragma warnings(off,”......“)”放入代码的违规部分?

See http://www.adacore.com/2007/11/19/ada-gem-18/.