6

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?

Jesse Rusak
  • 56,530
  • 12
  • 101
  • 102
Nayana Adassuriya
  • 23,596
  • 30
  • 104
  • 147
  • 2
    http://stackoverflow.com/q/2855121/390913 – perreal Oct 03 '14 at 09:17
  • 2
    See my [answer here](http://stackoverflow.com/a/25939282/1708801), in short you want `-std=c++11 -pedantic-errors` where c++11 is replaced with the standard you want to conform to. – Shafik Yaghmour Oct 03 '14 at 09:24
  • possible duplicate of [C++ array size declaration and const](http://stackoverflow.com/questions/25939260/c-array-size-declaration-and-const) – mmmmmm Oct 04 '14 at 23:15

1 Answers1

10

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