在配置/制作时将编译标志附加到CFLAGS和CXXFLAGS [英] Append compile flags to CFLAGS and CXXFLAGS while configuration/make

查看:585
本文介绍了在配置/制作时将编译标志附加到CFLAGS和CXXFLAGS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要构建的项目具有默认标志

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

但是我想在运行configuremake

帖子 在何处添加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.

或者,大多数默认启用-Werrorconfigure脚本也具有诸如--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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆