list supported standards gcc

  
gcc -v --help 2> /dev/null | sed -n '/^ *-std=\([^<][^ ]\+\).*/ {s//\1/p}'
  

Note you can tag on a | grep c++ or | grep c to get the standards supported by a particular langauge


Explanation

Step 1: gcc -v --help 2> /dev/null

Step 2: | sed -n '...'

Step 3: The sed script

/^ *-std=\([^<][^ ]\+\).*/ { s//\1/p }

a) Pattern match: ^ *-std=\([^<][^ ]\+\).*

This pattern looks for lines like:

  -std=c++17
-std=c++20

It avoids matches like -std=<something>.

b) Action block: { s//\1/p }

Effectively, it takes a line like:

  -std=c++17

and outputs:

c++17

Summary

c++98
c++03
c++11
c++14
c++17
c++20
c++23

edit this page