Macros
Prev | Chapter 3. Using | Next

## Macros

All library macros begin with `_GLIBCXX_`.

Furthermore, all pre-processor macros, switches, and configuration options are gathered in the file `c++config.h`, which is generated during the libstdc++ configuration and build process. This file is then included when needed by files part of the public libstdc++ API, like `<ios>`. Most of these macros should not be used by consumers of libstdc++, and are reserved for internal implementation use. These macros cannot be redefined.

A select handful of macros control libstdc++ extensions and extra features, or provide versioning information for the API. Only those macros listed below are offered for consideration by the general public.

Below are the macros which users may check for library version information.

`_GLIBCXX_RELEASE`

  The major release number for libstdc++. This macro is defined to the GCC major version that the libstdc++ headers belong to, as an integer constant. When compiling with GCC it has the same value as GCC's pre-defined macro __GNUC__. This macro can be used when libstdc++ is used with a non-GNU compiler where __GNUC__ is not defined, or has a different value that doesn't correspond to the libstdc++ version. This macro first appeared in the GCC 7.1 release and is not defined for GCC 6.x or older releases.

`__GLIBCXX__`

  The revision date of the libstdc++ source code, in compressed ISO date format, as an unsigned long. For notes about using this macro and details on the value of this macro for a particular release, please consult the ABI History appendix.

Below are the macros which users may change with #define/#undef or with -D/-U compiler flags. The default state of the symbol is listed.

“Configurable” (or “Not configurable”) means that the symbol is initially chosen (or not) based on --enable/--disable options at library build and configure time (documented in Configure), with the various --enable/--disable choices being translated to #define/#undef).

ABI-changing means that changing from the default value may mean changing the ABI of compiled code. In other words, these choices control code which has already been compiled (i.e., in a binary such as libstdc++.a/.so). If you explicitly #define or #undef these macros, the headers may see different code paths, but the libraries which you link against will not. Experimenting with different values with the expectation of consistent linkage requires changing the config headers before building/installing the library.

`_GLIBCXX_USE_DEPRECATED`

  Defined to the value `1` by default. Not configurable. ABI-changing. Turning this off removes older ARM-style iostreams code, and other anachronisms from the API. This macro is dependent on the version of the standard being tracked, and as a result may give different results for different `-std` options. This may be useful in updating old C++ code which no longer meet the requirements of the language, or for checking current code against new language standards.

`_GLIBCXX_USE_CXX11_ABI`

  Defined to the value `1` by default. Configurable via `--disable-libstdcxx-dual-abi` and/or `--with-default-libstdcxx-abi`. ABI-changing. When defined to a non-zero value the library headers will use the new C++11-conforming ABI introduced in GCC 5, rather than the older ABI introduced in GCC 3.4. This changes the definition of several class templates, including `std:string`, `std::list` and some locale facets. For more details see Dual ABI.

`_GLIBCXX_CONCEPT_CHECKS`

  Undefined by default. Configurable via `--enable-concept-checks`. When defined, performs compile-time checking on certain template instantiations to detect violations of the requirements of the standard. This macro has no effect for freestanding implementations. This is described in more detail in Compile Time Checks.

`_GLIBCXX_ASSERTIONS`

  Undefined by default. When defined, enables extra error checking in the form of precondition assertions, such as bounds checking in strings and null pointer checks when dereferencing smart pointers.

`_GLIBCXX_DEBUG`

  Undefined by default. When defined, compiles user code using the debug mode. When defined, `_GLIBCXX_ASSERTIONS` is defined automatically, so all the assertions enabled by that macro are also enabled in debug mode.

`_GLIBCXX_DEBUG_PEDANTIC`

  Undefined by default. When defined while compiling with the debug mode, makes the debug mode extremely picky by making the use of libstdc++ extensions and libstdc++-specific behavior into errors.

`_GLIBCXX_DEBUG_BACKTRACE`

  Undefined by default. Considered only if libstdc++ has been configured with `--enable-libstdcxx-backtrace=yes` and if `_GLIBCXX_DEBUG` is defined. When defined display backtraces on debug mode assertions.

`_GLIBCXX_PARALLEL`

  Undefined by default. When defined, compiles user code using the parallel mode.

`_GLIBCXX_PARALLEL_ASSERTIONS`

  Undefined by default, but when any parallel mode header is included this macro will be defined to a non-zero value if `_GLIBCXX_ASSERTIONS` has a non-zero value, otherwise to zero. When defined to a non-zero value, it enables extra error checking and assertions in the parallel mode.

`__STDCPP_WANT_MATH_SPEC_FUNCS__`

  Undefined by default. When defined to a non-zero integer constant, enables support for ISO/IEC 29124 Special Math Functions.

`_GLIBCXX_SANITIZE_VECTOR`

  Undefined by default. When defined, `std::vector` operations will be annotated so that AddressSanitizer can detect invalid accesses to the unused capacity of a `std::vector`. These annotations are only enabled for `std::vector<T, std::allocator<T>>` and only when `std::allocator` is derived from `new_allocator` or `malloc_allocator`. The annotations must be present on all vector operations or none, so this macro must be defined to the same value for all translation units that create, destroy, or modify vectors.

Prev | Up | Next
Headers | Home | Dual ABI