This page lists the available options for the C++ Compiler Options project.

🔗

Navigation

🔗

Options

The first value corresponds to the one used by default, and the value `default` has no associated behavior.

🔗

Warning options

warnings
Warning level.
  • on
  • default
  • off: Activates essential warnings and extras.
  • essential: Activates essential warnings, typically `-Wall -Wextra` or `/W4`).
  • extensive: Activates essential warnings, extras and some that may raise false positives
warnings_as_error
Make all or some warnings into errors.
  • default
  • off
  • on
  • basic
bidi_char_warnings
Enable warnings for possibly misleading Unicode bidirectional control characters. Set to `default` or `unpaired_and_ucn` in cases where some of the source code is expected to include bidirectional control characters.
  • any
  • default
  • any_and_ucn
  • unpaired
  • unpaired_and_ucn
conversion_warnings
Warn for implicit conversions that may alter a value.
  • on
  • default
  • off: Combine conversion and sign value
  • sign: Warn for implicit conversions that may change the sign (the `unsigned_integer = signed_integer`) or a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned.
  • float: Warn for implicit conversions that reduce the precision of a real value.
  • conversion: Warn for implicit conversions that may alter a value.
  • all: Like conversion and also warn about implicit conversions from arithmetic operations even when conversion of the operands to the same type cannot change their values.
covered_switch_default_warnings
Warning for default label in switch which covers all enumeration values.
  • on
  • default
  • off
msvc_crt_secure_no_warnings
Disable CRT warnings with MSVC.
  • on
  • default
  • off
noexcept_warnings
Warn when a noexcept-expression evaluates to false because of a call to a function that does not have a non-throwing exception specification (i.e. "throw()" or "noexcept") but is known by the compiler to never throw an exception. Only with GCC.
  • default
  • off
  • on
reproducible_build_warnings
Warn when macros "__TIME__", "__DATE__" or "__TIMESTAMP__" are encountered as they might prevent bit-wise-identical reproducible compilations.
  • default
  • off
  • on
shadow_warnings
  • off
  • default
  • on
  • local
  • compatible_local
  • all
suggest_attributes
Warn for cases where adding an attribute may be beneficial. With GCC, this analysis requires option `-fipa-pure-const`, which is enabled by default at `-O1` and higher.
  • on
  • default
  • off: Suggests noreturn attribute with Clang and GCC.
  • common: Suggests noreturn and format attributes with GCC ; noreturn with Clang.
  • analysis: Suggests noreturn, format attributes, malloc and returns_nonnull attributes with GCC ; noreturn with Clang.
  • unity: Suggests noreturn, format attributes and final on types and methods ; noreturn with Clang.
  • all: Active all suggestions for attributes.
switch_warnings
Warnings concerning the switch keyword.
  • on
  • default
  • off
  • exhaustive_enum
  • mandatory_default
  • exhaustive_enum_and_mandatory_default
unsafe_buffer_usage_warnings
Enable `-Wunsafe-buffer-usage` with Clang (https://clang.llvm.org/docs/SafeBuffers.html).
  • default
  • on
  • off
windows_abi_compatibility_warnings
In code that is intended to be portable to Windows-based compilers the warning helps prevent unresolved references due to the difference in the mangling of symbols declared with different class-keys.
  • off
  • default
  • on
🔗

Pedantic options

pedantic
Issue all the warnings demanded by strict ISO C and ISO C++.
  • on
  • default
  • off
  • as_error
stl_fix
Enable `/DNOMINMAX` with MSVC.
  • on
  • default
  • off
🔗

Debug options

symbols
Produce debugging information in the operating system's.
  • default
  • hidden: Use `-fvisibility=hidden` with Clang, GCC and other compilers that support this flag.
  • strip_all: Strip all symbols.
  • gc_sections: Enable garbage collection of unused sections.
  • nodebug: Request no debugging information.
  • debug: Request debugging information. How much information can be controlled with options `minimal_debug` and `full_debug`.
  • minimal_debug: If possible, produces information for tracebacks only. This includes descriptions of functions and external variables, and line number tables, but no information about local variables. If the level is not supported by a compiler, this is equivalent to the `debug` option.
  • full_debug: If possible, includes extra information, such as all the macro definitions present in the program.
  • btf: GCC only. Request BTF debug information. BTF is the default debugging format for the eBPF target.
  • codeview: GCC only. Code View debug format (used by Microsoft Visual C++ on Windows).
  • ctf: GCC only. Produce a CTF debug information. The default level is 2.
  • ctf1: Level 1 produces CTF information for tracebacks only. This includes callsite information, but does not include type information.
  • ctf2: Level 2 produces type information for entities (functions, data objects etc.) at file-scope or global-scope only.
  • vms: GCC only. Alpha/VMS debug format (used by DEBUG on Alpha/VMS systems).The default level is 2.
  • vms1: Same as `minimal_debug`, but for Alpha/VMS.
  • vms2: Same as `debug`, but for Alpha/VMS.
  • vms3: Same as `full_debug`, but for Alpha/VMS.
  • dbx: Clang only.
  • lldb: Clang only.
  • sce: Clang only.
  • dwarf: Clang-cl only
stl_hardening
Hardening allows turning some instances of undefined behavior in the standard library into a contract violation.
  • default
  • off
  • fast: A set of security-critical checks that can be done with relatively little overhead in constant time and are intended to be used in production. No impact on the ABI.
  • extensive: All the checks from fast mode and some additional checks for undefined behavior that incur relatively little overhead but aren't security-critical. No impact on the ABI.
  • debug: Enables all the available checks, including heuristic checks that might have significant performance overhead as well as internal library assertions. No impact on the ABI.
  • debug_with_broken_abi: Debug mode with ABI incompatibility for more check.
sanitizers
Enable sanitizers (asan, ubsan, etc) when available.
  • default
  • off
  • on: Enable address sanitizer and other compatible sanitizers
  • with_minimal_code_size: Enable address sanitizer and other compatible sanitizers, but reduces code size by removing the possibility of deleting checks via an environment variable when possible (use `-fsanitize-address-use-after-return=runtime` with Clang family).
  • extra: Enable address sanitizer and other compatible sanitizers, even those who require a config via environment variable.
  • extra_with_minimal_code_size: Combines `extra` and `with_minimal_code_size` values.
  • address: Enable address sanitizer only.
  • address_with_minimal_code_size: Enable address sanitizer only, but reduces code size by removing the possibility of deleting checks via an environment variable when possible (use `-fsanitize-address-use-after-return=runtime` with Clang family).
  • thread: Enable thread sanitizer.
  • undefined: Enable undefined sanitizer.
  • undefined_minimal_runtime: Enable undefined sanitizer with minimal UBSan runtime when available (Clang>=6).
  • scudo_hardened_allocator: Enable Scudo Hardened Allocator with Clang. See https://llvm.org/docs/ScudoHardenedAllocator.html.
var_init
Initialize all stack variables implicitly, including padding.
  • default
  • uninitialized: Doesn't initialize any automatic variables (default behavior of Clang and GCC).
  • pattern: Initialize automatic variables with byte-repeatable pattern (0xFE for GCC, 0xAA for Clang).
  • zero: zero Initialize automatic variables with zeroes.
emcc_debug
Add checks with Emscripten compiler.
  • default
  • off: Disable checks used with default `-O0` optimization.
  • on: Activate some checks in addition to those used with default `-O0` optimization.
  • slow: Activate checks that can greatly slow down the program.
ndebug
Enable `NDEBUG` macro (disable assert macro).
  • with_optimization_1_or_above
  • default
  • off
  • on
optimization
Optimization level.
  • default
  • 0: Not optimize.
  • g: Enable debugging experience.
  • 1: Optimize.
  • 2: Optimize even more.
  • 3: Optimize yet more.
  • fast: Enables all `optimization=3` and disregard strict standards compliance.
  • size: Optimize for size.
  • z: Optimize for size aggressively (âš  possible slow compilation with emcc).
🔗

Optimization options

cpu
  • default
  • generic
  • native
lto
Enable Link Time Optimization. Also known as interprocedural optimization (IPO).
  • default
  • off
  • on: Activates ThinLTO when available (Clang), otherwise FullLTO.
  • full: Activates FullLTO.
  • thin_or_nothing: Activates ThinLTO. Disable lto when not supported.
  • whole_program: Assume that the current compilation unit represents the whole program being compiled. This option should not be used to compile a library. When not supported by the compiler, ThinLTO or FullLTO are used.
  • whole_program_and_full_lto: Same as `whole_program`, but use FullLTO when not supported.
optimization
Optimization level.
  • default
  • 0: Not optimize.
  • g: Enable debugging experience.
  • 1: Optimize.
  • 2: Optimize even more.
  • 3: Optimize yet more.
  • fast: Enables all `optimization=3` and disregard strict standards compliance.
  • size: Optimize for size.
  • z: Optimize for size aggressively (âš  possible slow compilation with emcc).
optimization_warnings
Activate warnings about optimization.
  • default
  • off
  • on
🔗

C++ options

exceptions
Enable C++ exceptions.
  • default
  • off
  • on
rtti
Disable generation of information about every class with virtual functions for use by the C++ run-time type identification features ("dynamic_cast" and "typeid").
  • default
  • off
  • on
🔗

Hardening options

hardened
Enable a set of flags for C and C++ that improve the security of the generated code without affecting its ABI. Can impact performance.
  • default
  • off: Use `/GS-` with MSVC-like compiler. Does nothing with other compilers.
  • on
  • all: Use -fstack-protector-all instead of -fstack-protector-strong
stl_hardening
Hardening allows turning some instances of undefined behavior in the standard library into a contract violation.
  • default
  • off
  • fast: A set of security-critical checks that can be done with relatively little overhead in constant time and are intended to be used in production. No impact on the ABI.
  • extensive: All the checks from fast mode and some additional checks for undefined behavior that incur relatively little overhead but aren't security-critical. No impact on the ABI.
  • debug: Enables all the available checks, including heuristic checks that might have significant performance overhead as well as internal library assertions. No impact on the ABI.
  • debug_with_broken_abi: Debug mode with ABI incompatibility for more check.
🔗

Static Analyzer options

analyzer
Enables an static analysis. It can have false positives and false negatives. It is a bug-finding tool, rather than a tool for proving program correctness. Available only with GCC and MSVC.
  • default
  • off
  • on: Enables an static analysis and ignore external headers with MSVC.
  • with_external_headers: Enables an static analysis.
analyzer_too_complex_warning
By default, the analysis silently stops if the code is too complicated for the analyzer to fully explore and it reaches an internal limit. This option warns if this occurs. Available only with GCC.
  • default
  • off
  • on
analyzer_verbosity
Controls the complexity of the control flow paths that are emitted for analyzer diagnostics. Available only with GCC.
  • default
  • 0: At this level, interprocedural call and return events are displayed, along with the most pertinent state-change events relating to a diagnostic. For example, for a double-free diagnostic, both calls to free will be shown.
  • 1: As per the previous level, but also show events for the entry to each function.
  • 2: As per the previous level, but also show events relating to control flow that are significant to triggering the issue (e.g. "true path taken" at a conditional). This level is the default.
  • 3: As per the previous level, but show all control flow events, not just significant ones.
🔗

Other options

color
  • default
  • auto
  • never
  • always
coverage
  • default
  • off
  • on
diagnostics_format
Emit fix-it hints in a machine-parseable format.
  • default
  • fixits
  • patch
  • print_source_range_info
diagnostics_show_template
Configures how templates with incompatible types are displayed (Clang and GCC only).
  • default
  • tree: Enables printing a tree-like structure showing the common and differing parts of the types
  • without_elided_types: Disables printing diagnostics showing common parts of template types as "[...]".
  • tree_without_elided_types: Prints a tree-like without replacing common types. Mergeing `tree` and `without_elided_types`.
linker
Configure linker.
  • default
  • bfd
  • gold
  • lld
  • mold
  • native
msvc_diagnostics_format
Controls the display of error and warning information (https://learn.microsoft.com/en-us/cpp/build/reference/diagnostics-compiler-diagnostic-options).
  • caret
  • default: Which reports only the line number where the issue was found.
  • classic: Includes the column where the issue was found. This can help you identify the specific language construct or character that is causing the issue.
  • column: Includes the column where the issue was found and places a caret (^) under the location in the line of code where the issue was detected.
msvc_isystem
Warnings concerning external header (https://devblogs.microsoft.com/cppblog/broken-warnings-theory).
  • default
  • anglebrackets
  • include_and_caexcludepath
  • external_as_include_system_flag
  • assumed: Do not activate `/external:W0`, but considers the option as activated so that `warnings=on` or more activates more warnings.
msvc_isystem_with_template_instantiations_treated_as_non_external
Allows warnings from external headers when they occur in a template that's instantiated in your code. (requires `msvc_isystem` option).
  • default
  • off
  • on
windows_bigobj
Increases that addressable sections capacity.
  • on
  • default
🔗

Profiles

debug
  • emcc_debug = on
  • sanitizers = on
  • stl_hardening = debug
  • symbols = debug
debug_optimized
  • optimization = g
  • symbols = debug
minimum_size_release
  • lto = on
  • optimization = size
release
  • lto = on
  • optimization = 3