unrecognized command-line option C/C++ Origin: Application & API OSI layer 7 · Application Last updated 28 Nov 2026

g++: error: unrecognized command-line option '-std=c++20'

The compiler does not know the flag you passed — usually because it is too old.

Exact message you may see unrecognized command-line optionunrecognized command line optionunknown argument
Seen on: C/C++ GCC Clang

Meaning

Newer standards need newer compilers. Check g++ --version; or the flag is misspelled.

Common causes

  • Compiler too old
  • Typo in flag
  • Clang flag passed to GCC (or reverse)

⚡ Quick fix

  1. Upgrade the compiler
  2. Use -std=c++2a on older GCC
  3. Fix spelling

Detailed fix by platform

Linux

  1. sudo apt install g++-12 then CXX=g++-12

How to diagnose

  1. Version — Compiler version?
  2. Flag — Spelling?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

cannot bind non-const lvalue reference — C++: error: cannot bind non-const lvalue reference of type 'T&' to an rvalue of type 'T' (C/C++)cannot bind non-const…case label does not reduce to an integer constant — C/C++: error: case label does not reduce to an integer constant (C/C++)case label does not r…conflicting types — C: error: conflicting types for 'foo' (C/C++)conflicting typesD8016 — MSVC: command line error D8016: '/RTC1' and '/O2' command-line options are incompatible (C/C++)D8016does not name a type — C++: error: 'string' does not name a type (C/C++)does not name a typeNo CMAKE_CXX_COMPILER could be found — CMake Error: No CMAKE_CXX_COMPILER could be found (C/C++)No CMAKE_CXX_COMPILER…not a constant expression — C++: error: call to non-'constexpr' function / expression is not a constant expression (C/C++)not a constant expres…only available with — C++: warning: structured bindings / inline variables only available with '-std=c++17' or '-std=gnu++17' (C/C++)only available withunrecogni…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.