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

**Code:** `unrecognized command-line option` · **Category:** C/C++ · **Seen on:** C/C++, GCC, Clang

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/cpp/unrecognized-command-line-option)
