在automake / gcc中混合使用C ++ 98和C ++ 11源代码 [英] Mixing C++98 and C++11 source in automake/gcc

查看:237
本文介绍了在automake / gcc中混合使用C ++ 98和C ++ 11源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



其中一些是使用pre-C ++ 11标准编写的(即C ++ 98),并且它们不能用c ++ 11来编译gcc(-std = c ++ 11)。



最新的cpp文件使用C ++ 11标准,他们需要在编译中使用-std = c ++ 11标志。

我可以在Automake中定义两个cpp源文件列表并给出不同的编译标志吗?

解决方案

这是直接从使用automake设置每个文件的标志



你可以将你的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源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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