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.
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.
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.
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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.