停止将警告视为错误

时间:2015-03-05 18:04:53

标签: c linux compiler-errors makefile

我尝试make小代理服务器tcproxy

user@localhost:tcproxy $ make
cd src && make all
make[1]: Entering directory '/home/user/Downloads/tcproxy/src'
    CC anet.o
In file included from /usr/include/sys/types.h:25:0,
                 from anet.c:33:
/usr/include/features.h:148:3: error: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Werror=cpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
   ^
cc1: all warnings being treated as errors
Makefile:26: recipe for target 'anet.o' failed
make[1]: *** [anet.o] Error 1
make[1]: Leaving directory '/home/user/Downloads/tcproxy/src'
Makefile:10: recipe for target 'all' failed
make: *** [all] Error 2

编译失败,因为all warnings are being treated as errors

它在两年内没有更新,似乎警告只是来自某个被弃用的东西,但我希望它仍然有效。

我已经用Google搜索了如何阻止所有警告被视为错误;有人建议使用-Wno-error,但这在我的案例中没有任何区别。

如何强制编辑?

注意

Makefile只包含:

#
# tcproxy - Makefile
#
# Author: dccmx <dccmx@dccmx.com>
#

default: all

.DEFAULT:
    cd src && $(MAKE) $@

2 个答案:

答案 0 :(得分:4)

src/Makefile中有一行定义:

CFLAGS_GEN = -Wall -Werror -g $(CFLAGS)

删除-Werror,你得到的警告会被忽略。

答案 1 :(得分:0)

这些是编译器选项,而不是make选项,要清楚。

您需要找到make调用编译器时使用的选项。在makefile中查找选项-Werror,并将其从包含在其中的任何变量中删除(可能CFLAGS或某些变体)。