问题描述
其中一些是使用pre-C ++ 11标准编写的(即C ++ 98),并且它们不能用c ++ 11来编译gcc(-std = c ++ 11)。
最新的cpp文件使用C ++ 11标准,他们需要在编译中使用-std = c ++ 11标志。
我可以在Automake中定义两个cpp源文件列表并给出不同的编译标志吗?
这是直接从
你可以将你的c ++ 11代码绑定到一个lib中,并提供不同的标志Makefile.am中的这个代码子集
bin_PROGRAMS = test
test_SOURCES = main.cpp
test_LDADD = c11code .la
noinst_LTLIBRARIES = c11code.la
c11code_la_SOURCES = cxx1_1.cpp cxx1_2.cpp cxx1_3.cpp
c11code_la_CXXFLAGS = $(CXXFLAGS)-std = c ++ 11
I have a list of cpp files in project which is built using automake tools.
Some of them are written using pre-C++11 standard (ie C++98) and they cannot compile with c++11 flag of gcc (-std=c++11).
Latest cpp files are using C++11 standard and they need -std=c++11 flag in compile.
Can I define in Automake two lists of cpp source files and give different compilation flags?
This is ripped directly from Setting per-file flags with automake
You may bundle your c++11 code into a lib and provide different flags for this code subset in Makefile.am
bin_PROGRAMS = test
test_SOURCES = main.cpp
test_LDADD = c11code.la
noinst_LTLIBRARIES = c11code.la
c11code_la_SOURCES = cxx1_1.cpp cxx1_2.cpp cxx1_3.cpp
c11code_la_CXXFLAGS = $(CXXFLAGS) -std=c++11
这篇关于在automake / gcc中混合使用C ++ 98和C ++ 11源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!