在配置/制作时将编译标志附加到CFLAGS和CXXFLAGS [英] Append compile flags to CFLAGS and CXXFLAGS while configuration/make
问题描述
我要构建的项目具有默认标志
The project that I am trying to build has default flags
CFLAGS = -Wall -g -O2
CXXFLAGS = -g -O2
我需要在这两个变量上附加一个标志-w
(以删除:将所有警告视为错误")
I need to append a flag -w
to both these variables (to remove: 'consider all warnings as errors')
我有办法解决,给
make 'CFLAGS=-Wall -g -O2 -w'; 'CXXFLAGS=-g -O2 -w'
OR
运行./configure
并静态修改Makefile
但是我想在运行configure
或make
帖子 在何处添加CFLAG,例如-std = gnu99进入自动工具项目 方便地使用宏来实现这一点.
The post Where to add a CFLAG, such as -std=gnu99, into an autotools project conveniently uses a macro to achieve this.
推荐答案
您几乎完全正确;为什么要添加分号?
You almost have it right; why did you add the semicolon?
要在configure
行上执行此操作,
./configure CFLAGS='-g -O2 -w' CXXFLAGS='-g -O2 -w'
要在make
行上执行此操作,
make CFLAGS='-g -O2 -w' CXXFLAGS='-g -O2 -w'
但是,这并不能真正消除将所有警告视为错误;删除所有警告.因此,同时指定-Wall
和-w
没有任何意义.如果要保留警告但不将其视为错误,请使用-Wall -Wno-error
标志.
However, that doesn't really remove consider all warnings as errors; that removes all warnings. So specifying both -Wall
and -w
doesn't make sense. If you want to keep the warnings but not have them considered errors, use the -Wall -Wno-error
flags.
或者,大多数默认启用-Werror
的configure
脚本也具有诸如--disable-werror
或类似标记的标志.运行./configure --help
,看看是否有类似的东西.
Alternatively, most configure
scripts which enable -Werror
by default also have a flag such as --disable-werror
or similar. Run ./configure --help
and see if there's something like that.
这篇关于在配置/制作时将编译标志附加到CFLAGS和CXXFLAGS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!