Search code examples
c++macosgccc++11terminal

Making -std=c++11 the default in mac terminal


When I want to compile, I need to specify -std=c++11 like this:

g++ -Wall -std=c++11 main.cpp -o main

and I wonder if there was a solution to set the -std=c++11 flag permanently so it will be possible to do:

 g++ -Wall main.cpp -o main

without flags.


Solution

  • Create an alias: alias g++='g++ -std=c++11' should do the trick.

    (However, the version of GCC that comes with OS X is so ancient that it doesn't support C++11, you'd be better off using clang and clang++.)