All pre-processor switches and configurations are all gathered
in the file c++config.h
, which is generated during
the libstdc++ configuration and build process, and included by
files part of the public libstdc++ API. Most of these macros
should not be used by consumers of libstdc++, and are reserved
for internal implementation use. These macros cannot be
redefined. However, a select handful of these macro
control libstdc++ extensions and extra features, or provide
versioning information for the API, and are able to be used.
All library macros begin with _GLIBCXX_
(except for
versions 3.1.x to 3.3.x, which use _GLIBCPP_
).
Below is the macro which users may check for library version information.
__GLIBCXX__
The current version of libstdc++ in compressed ISO date format, form of an unsigned long. For details on the value of this particular macro for a particular release, please consult this document.
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 here), with the various --enable/--disable choices being translated to #define/#undef).
ABI 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_DEPRECATED
Defined 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
-std=c++98
and -std=c++0x
. 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_FORCE_NEW
Undefined by default. When defined, memory allocation and
allocators controlled by libstdc++ call operator new/delete
without caching and pooling. Configurable via
--enable-libstdcxx-allocator
. ABI-changing.
_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
is described in more detail here.
_GLIBCXX_DEBUG
Undefined by default. When defined, compiles user code using the 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_PARALLEL
Undefined by default. When defined, compiles user code using the parallel mode.