Reputation: 21
I have been using Ubuntu for so long, and a few days before I decided to switch to Linux Mint. On ubuntu, I never had any problems on compiling C++ source code written for the c++14
standard. But on Mint, the default standard is c++98
. I tried to make an alias as follows:
alias g++="g++ -std=c++14
and it worked for small programs that I manually compile. However, this is not a solution for automatic software building with Makefiles, so I want to tell g++ to use c++14
as the default ISO. Thanks for your help
I want this for me, more concretly I want to do something like:
std::vector<int> numbers = {1, 2, 3, 4, 5};
Upvotes: 2
Views: 14962
Reputation: 3816
That's just not how compilers and software distribution on Linux distributions work.
There are many build systems, ranging from plan Makefiles, Autotools, scons, CMake, qmake, waf, Bazel, Buck, Mezon... you name it. Each and every one of these has a distinct method on how to specify the compiler and its options.
A compiler's default settings also affect behavior, and these defaults are different in each compiler's version.
Also, as a user, or someone who is "just" compiling software written by someone else, you should not be overriding the author's idea about a language standard in the general case. Doing that it potentially dangerous.
If, however, this is about your own software and your convenience, then my suggestion is to use a real build system which lets you specify the compiler options and the language standard globally, from one location. You are also setting other non-default flags such as -Wall
, aren't you?
Upvotes: -1
Reputation:
Set an environment variable in one of your .rc
scripts:
export CXXFLAGS = "$CXXFLAGS -std=c++14"
that should affect all calls to make
unless the variable is explicitly set in the Makefile
again.
Another option is to provide a config.mak
file, you can include in your Makefile
s:
Makefile
:include config.mak
# ... rules and actions
config.mak
:CXXFLAGS += "-std=c++14"
Upvotes: 2