user11664129
user11664129

Reputation:

how to change std flag of clang in mac? current clang version 10.0.1 is using c++98 flag

Though documentation of clang says version 10.0.1 uses c++11 but I am trying to compile c++ programs using clang compiler and clang compiler explicitly need -std=c++11 flag to compile with c++11 version.Otherwise it gives error in codes.

Upvotes: 0

Views: 1019

Answers (1)

lubgr
lubgr

Reputation: 38315

What the documentation might mean is that new XCode projects have these std=c++11 flags burried in their configuration by default. This doesn't necessarily mean that the command-line clang++ executable uses this as a default.

You can create an alias, e.g.

alias clang++="clang++ -std=c++11"

to circumvent this issue for ad-hoc command line usage. Within real projects, you will have to maintain the build settings and compiler flags anyhow, so adding your desired C++ standard flag should be a simple task.

Upvotes: 1

Related Questions