Mixing C++98 and C++11 source in automake/gcc

你离开我真会死。 提交于 2019-12-11 16:15:46

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/26906219/mixing-c98-and-c11-source-in-automake-gcc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!