Library Configuration module
Preprocessor macros for configuring library functionality.
Define these before including toml++ to alter the way it functions.
Defines
- #define TOML_ASSERT(expr)
- Sets the assert function used by the library.
- #define TOML_CALLCONV
- Calling convention to apply to exported free/static functions.
- #define TOML_CONFIG_HEADER
- An additional header to include before any other toml++ header files.
- #define TOML_DISABLE_CONDITIONAL_NOEXCEPT_LAMBDA
- Disable using noexcept(<condition>) in lambda definitions within the toml++ library implementation.
- #define TOML_DISABLE_NOEXCEPT_NOEXCEPT
- Disable using noexcept(noexcept(<expression>)) within the toml++ library implementation.
- #define TOML_ENABLE_CHRONO
- Sets whether conversions to and from the C++20
std::chronotypes are enabled. - #define TOML_ENABLE_FLOAT16
- Enable support for the built-in
_Float16type. - #define TOML_ENABLE_FORMATTERS
- Sets whether the various formatter classes are enabled.
- #define TOML_ENABLE_PARSER
- Sets whether the parser-related parts of the library are included.
- #define TOML_ENABLE_UNRELEASED_FEATURES
- Enables support for unreleased TOML language features not yet part of a numbered version.
- #define TOML_ENABLE_WINDOWS_COMPAT
- Enables the use of wide strings (wchar_t, std::
wstring) in various places throughout the library when building for Windows. - #define TOML_EXCEPTIONS
- Sets whether the library uses exceptions to report parsing failures.
- #define TOML_EXPORTED_CLASS
- An 'export' annotation to add to classes.
- #define TOML_EXPORTED_FREE_FUNCTION
- An 'export' annotation to add to free functions.
- #define TOML_EXPORTED_MEMBER_FUNCTION
- An 'export' annotation to add to non-static class member functions.
- #define TOML_EXPORTED_STATIC_FUNCTION
- An 'export' annotation to add to
staticclass member functions. - #define TOML_FLOAT_CHARCONV
- Use
std::from_chars()andstd::to_chars()to parse and print floats. - #define TOML_HEADER_ONLY
- Sets whether the library is entirely inline.
- #define TOML_IMPLEMENTATION
- Enables the library's implementation when TOML_
HEADER_ ONLY is disabled. - #define TOML_INT_CHARCONV
- Has no effect. The library parses and prints integers without
<charconv>. - #define TOML_OPTIONAL_TYPE
- Overrides the
optional<T>type used by the library. - #define TOML_SMALL_FLOAT_TYPE
- If your codebase has an additional 'small' float type (e.g. half-precision), this tells toml++ about it.
- #define TOML_SMALL_INT_TYPE
- If your codebase has an additional 'small' integer type (e.g. 24-bits), this tells toml++ about it.
Define documentation
#define TOML_ASSERT(expr)
Sets the assert function used by the library.
Defaults to the standard C assert(). Ignored when NDEBUG is defined.
#define TOML_CALLCONV
Calling convention to apply to exported free/static functions.
Not defined by default (let the compiler decide).
#define TOML_CONFIG_HEADER
An additional header to include before any other toml++ header files.
Not defined by default.
#define TOML_DISABLE_CONDITIONAL_NOEXCEPT_LAMBDA
Disable using noexcept(<condition>) in lambda definitions within the toml++ library implementation.
This macro offers a workaround to a bug in the old "legacy lambda processor" of Visual C++, which caused compile errors like "error C2057: expected constant expression", when it encountered such lambda's. These compile errors are described at https:/1 for MSVC before C++20, which uses the legacy lambda processor unless /permissive- or /Zc:lambda is given, and to 0 otherwise.
#define TOML_DISABLE_NOEXCEPT_NOEXCEPT
Disable using noexcept(noexcept(<expression>)) within the toml++ library implementation.
This macro offers a workaround to a bug in Visual C++ (Visual Studio 2022), which caused compile errors, saying: "error C3878: syntax error: unexpected token ',' following 'simple-type-specifier'" Defaults to 1 for Visual Studio 2022 version 17.13 and older, clang-cl included, and to 0 otherwise.
#define TOML_ENABLE_CHRONO
Sets whether conversions to and from the C++20 std::chrono types are enabled.
Defaults to 1 from C++20. It is always 0 before C++20, and with a libstdc++ older than GCC 11's, which lacks the calendar types.
#define TOML_ENABLE_FORMATTERS
Sets whether the various formatter classes are enabled.
Defaults to 1.
#define TOML_ENABLE_PARSER
Sets whether the parser-related parts of the library are included.
Defaults to 1.
#define TOML_ENABLE_UNRELEASED_FEATURES
Enables support for unreleased TOML language features not yet part of a numbered version.
Defaults to 0.
#define TOML_ENABLE_WINDOWS_COMPAT
Enables the use of wide strings (wchar_t, std::
Defaults to 1 when building for Windows, 0 otherwise. Has no effect when building for anything other than Windows.
#define TOML_EXCEPTIONS
Sets whether the library uses exceptions to report parsing failures.
Defaults to 1 or 0 according to your compiler's exception mode.
#define TOML_EXPORTED_FREE_FUNCTION
An 'export' annotation to add to free functions.
Not defined by default.
#define TOML_EXPORTED_MEMBER_FUNCTION
An 'export' annotation to add to non-static class member functions.
Not defined by default.
#define TOML_EXPORTED_STATIC_FUNCTION
An 'export' annotation to add to static class member functions.
Not defined by default.
#define TOML_FLOAT_CHARCONV
Use std::from_chars() and std::to_chars() to parse and print floats.
Defaults to 1 when the standard library has both for float and double: libstdc++ from GCC 11, the MSVC STL from Visual Studio 2019 16.4, and libc++ from version 20 (on Apple platforms, from a deployment target of macOS 26 or the matching iOS, tvOS and watchOS). Otherwise 0, which uses snprintf() and strtod() instead. Both give the same values and the same text; 1 is faster.
#define TOML_IMPLEMENTATION
Enables the library's implementation when TOML_
Not defined by default. Meaningless when TOML_
#define TOML_INT_CHARCONV
Has no effect. The library parses and prints integers without <charconv>.
Still defined for code that reads it: 1 when the standard library has <charconv>, except libc++ before version 15 on Apple platforms and Emscripten.
#define TOML_OPTIONAL_TYPE
Overrides the optional<T> type used by the library.
Not defined by default (use std::
#define TOML_SMALL_FLOAT_TYPE
If your codebase has an additional 'small' float type (e.g. half-precision), this tells toml++ about it.
Not defined by default.
#define TOML_SMALL_INT_TYPE
If your codebase has an additional 'small' integer type (e.g. 24-bits), this tells toml++ about it.
Not defined by default.