相关疑难解决方法(0)

CFLAGS,CCFLAGS,CXXFLAGS - 这些变量到底控制着什么?

我正在使用GNU make来编译我的C++代码,我想了解如何使我的编译可以自定义.

我在不同的地方阅读CFLAGS,CCFLAGSCXXFLAGS用于此目的.那我该怎么用呢?如果我有额外的命令行参数编译器,我应该将它们附加CFLAGS或前置它们吗?有共同的做法吗?

为什么三个不同的变量?我想C编译器应该得到CFLAGSCCFLAGS,而C++编译器应该得到CFLAGSCXXFLAGS-我有没有得到它吗?

人类用户是否应该设置这些变量?做任何自动化工具(automake,autoconf,等)设置它们?我应该使用的linux系统没有定义任何这些变量 - 这是典型的吗?

目前我的Makefile看起来像这样,我觉得它有点脏:

ifdef code_coverage
    GCOV_FLAG := -fprofile-arcs -ftest-coverage
else
    GCOV_FLAG :=
endif

WFLAGS := -Wall

INC_FLAGS := -Istuff -Imore_stuff -Ietc

CCFLAGSINT := -O3 $(WFLAGS) $(INC_FLAGS) $(CCFLAGS)

... (somewhere in the makefile, the command-line for compilation looks like this)
    $(CC) $(CCFLAGSINT) -c $< -o $@

... (somewhere in the makefile, the command-line for linking looks …
Run Code Online (Sandbox Code Playgroud)

gcc makefile naming-conventions

64
推荐指数
3
解决办法
10万
查看次数

标签 统计

gcc ×1

makefile ×1

naming-conventions ×1