Skip to content

[Solved] warning: ‘auto’ type specifier is a C++11 extension [-Wc++11-extensions]

Last Updated on 2021-09-18 by Clay

Problem

Today when I was programming on Mac OS, I found some old programs would issue the following warning when compiling:

warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]

In some tasks, even the compilation fails directly. After searching, I found that I couldn’t directly change the settings to make it take effect. I needed to add the -std=c++11 parameter when compiling, so I decided to change the ~/.bash_profile configuration file.

If you used another scripting language, change the corresponding configuration file.


Solution

Enter the following command in terminal:

echo 'alias g++="g++ -std=c++11"' >> ~/.bash_profile
source ~/.bash_profile

In this way, the -std=c++11 parameter will be included when compiling with g++ in the future. Try to compile and see, the original warning message should disappear.


References


Read More

Tags:

1 thought on “[Solved] warning: ‘auto’ type specifier is a C++11 extension [-Wc++11-extensions]”

Leave a ReplyCancel reply

Exit mobile version