Reputation: 1573
I'm using g++ 4.8.1, and unless I explicitly state -std=c++11
then it always compiles C++ code using the '98 standard. How do I permanently set the flag?
EDIT: Also, I'm using Windows. And command prompt.
Upvotes: 1
Views: 602
Reputation: 145194
g++ is configured via a spec file.
you can google that, and edit it.
alternatives to configuring the basic compiler via its spec file include
batch file to invoke it
console alias to invoke it (use doskey
command)
just use the Nuwen distribution, which is already configured for C++11.
Upvotes: 2
Reputation: 2404
You can create an alias for whichever shell you use. Usually, the alias must be stored in a start-up script for it to become permanent.
For bash:
alias g++='g++ -std=c++11'
For Window's cmd.exe:
doskey g++=g++ -std=c++11 $*
While you're at it, -Wall
and -pedantic
are also useful to set by default. Look them up!
Upvotes: 0
Reputation: 109079
Save the following line in a batch file, and call that instead, passing the arguments you'd normally pass to g++ to the batch file.
g++ -std=c++11 %*
This is the only reference I could find for %*
The %* modifier is a unique modifier that represents all arguments passed in a batch file.
Upvotes: 1