This page lists the available options for the C++ Compiler Options project.
The first value corresponds to the one used by default, and the value `default
` has no associated behavior.
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 positivesdefault
off
on
basic
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
on
default
off
: Combine conversion and sign valuesign
: 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.on
default
off
on
default
off
default
off
on
default
off
on
off
default
on
local
compatible_local
all
-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.on
default
off
exhaustive_enum
mandatory_default
exhaustive_enum_and_mandatory_default
-Wunsafe-buffer-usage
` with Clang (https://clang.llvm.org/docs/SafeBuffers.html).
default
on
off
off
default
on
on
default
off
as_error
/DNOMINMAX
` with MSVC.
on
default
off
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 onlydefault
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.default
off
on
: Enable address sanitizer and other compatible sanitizerswith_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.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.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
` macro (disable assert macro).
with_optimization_1_or_above
default
off
on
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).default
generic
native
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.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).default
off
on
default
off
on
default
off
on
default
off
: Use `/GS-
` with MSVC-like compiler. Does nothing with other compilers.on
all
: Use -fstack-protector-all instead of -fstack-protector-strongdefault
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.default
off
on
: Enables an static analysis and ignore external headers with MSVC.with_external_headers
: Enables an static analysis.default
off
on
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.default
auto
never
always
default
off
on
default
fixits
patch
print_source_range_info
default
tree
: Enables printing a tree-like structure showing the common and differing parts of the typeswithout_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
`.default
bfd
gold
lld
mold
native
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.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
` option).
default
off
on
on
default
emcc_debug
= onsanitizers
= onstl_hardening
= debugsymbols
= debugoptimization
= gsymbols
= debuglto
= onoptimization
= sizelto
= onoptimization
= 3