[cfe-users] Enable C++11 flag by default in clang?

Csaba Raduly rcsaba at gmail.com
Fri Jul 11 02:34:42 PDT 2014

Hi Matthias,

On Fri, Jul 11, 2014 at 8:45 AM, Matthias Maier  wrote:
> Am 11. Jul 2014, 03:49 schrieb Miguel Carvajal :
>> Hi, i'm trying to compile clang but before continue i want to know if
>> there is a way to turn on c++11 mode by default in the compiler.
>> I mean, turn the switch on so i don't have to type clang++ -std=c+11 every
>> time/
> Unfortunately, clang doesn't support a spec-file mechanism like gcc
> yet (at least it didn't when I checked). So the easiest way to achieve
> this is to use the alias mechanism of your shell:
> Depending on your shell add a line
>   alias clang++="clang++ -std=c++11"
> to ~/.bashrc (in case of bash) or ~/.zshrc (if it is zsh) or something
> else.

That might not work from make; by default SHELL=/bin/sh and not bash

You might be better off with a shell script, named e.g. clang++11,
placed somewhere in the PATH, containing:

exec clang++ -std=c++11 $*

GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

More information about the cfe-users mailing list