How can I compile only standard C++ with GNU g++?

2020-04-05 10:33发布

问题:

There are some extensions in the GNU g++ compilers such as VLA (variable length arrays), even though those features are not C++ standards.

So if I need to compile a program using only C++ standard constructs and avoiding those extra extensions, can I do it with GNU g++?

Something like g++ test.cpp -std=onlyStandards?

回答1:

Pass the -pedantic-errors flag. Be sure to set a standard with -std=, such as -std=c++14. This works in clang as well.



标签: c++ g++