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

2020-04-05 10:01发布

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?

标签: c++ g++
1条回答
兄弟一词,经得起流年.
2楼-- · 2020-04-05 10:25

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

查看更多
登录 后发表回答