The LLVM C++ compiler has full support for C++11 standard. Is there a way to set C++11 as the default standard without adding -std=c++11
compiler flag every time? I tried setting CCXFLAGS
environment variable to -std=c++11
, but with no luck.
Asked
Active
Viewed 8,699 times
11

compor
- 2,239
- 1
- 19
- 29

Szőke Szabolcs
- 511
- 7
- 19
-
To start with the environment variable should be `CXXFLAGS`, and I'm not sure that clang even checks it? – Some programmer dude Feb 05 '14 at 15:49
-
You say CCXFLAGS. Is this a typo in your question ? It should be CXXFLAGS. – François Moisan Feb 05 '14 at 15:50
-
1[This would do that for you but there must be better answers:][1] [1]: http://stackoverflow.com/questions/18040048/making-std-c11-the-default-in-mac-terminal – Novin Shahroudi Feb 05 '14 at 15:51
-
possible duplicate of [How do I enable C++11 in gcc?](http://stackoverflow.com/questions/16886591/how-do-i-enable-c11-in-gcc) – Ali Feb 05 '14 at 16:11
-
"LLVM C++ compiler has full support for C++11 standard". That is not actually quite true. Clang++ on Linux uses GNU's libstdc++ (by default), at it does not yet fully complies to the c++11 standard. BTW: CXXFLAGS is for Makefiles, not the compiler. – Torkel Bjørnson-Langen Feb 06 '14 at 08:01
-
Don't use `CXXFLAGS`, use `CXX` for dialect options, as these may affect the linker as well, e.g., `CXX="clang++ -std=c++11 -stdlib=libc++"` - invoke it on the command line with `$CXX`, and let build tools pick up `CXX`. – Brett Hale Feb 06 '14 at 15:31
2 Answers
1
Use clang 6.0.0 or higher. The default C++ dialect is now C++14.
http://releases.llvm.org/6.0.1/tools/clang/docs/ReleaseNotes.html#c-language-changes-in-clang

Bulletmagnet
- 5,665
- 2
- 26
- 56