C++ Flags & Options
The C++ language, standard library and compilers.All C++ pages
- g++ -c: compile C++ to an object file without linkingg++ -c compiles a C++ file to an object file without linking: separate compilation, relinking after a change, -E/-S/-c stages and common link errors to fix.
- g++ -E: show the preprocessed C++ source (debug macros and #include)g++ -E prints the preprocessed C++ source: see macro expansion, #ifdef branches and included headers, with -P, -dM, -H and tips for debugging C++ macros.
- g++ -pedantic-errors and -Wpedantic: reject non-standard C++ extensionsg++ -pedantic-errors and -Wpedantic reject non-standard C++ extensions such as VLAs and early designated initializers. Levels, examples and portable fixes.
- g++ -std=c++17: choose the C++ standard versiong++ -std=c++17 selects the C++ standard; use c++20 or c++23 for newer features. GCC 11+ defaults to gnu++17. Values, __cplusplus numbers and the CMake setting.