Skip to content

v2_0_cpp_configure

Takatoshi Kondo edited this page Aug 3, 2022 · 6 revisions

Configuration (preprocessor macro)

MSGPACK_NO_BOOST (since 4.1.0)

Default value: not defined. Remove boost libraries dependecy ans use internal copied and modified boost library.

MSGPACK_USE_BOOST (since 1.2.0)(until 4.0.0)

Default value: not defined.

msgpack-c supports boost containers. See https://github.com/msgpack/msgpack-c/tree/master/include/msgpack/adaptor/boost When you use these adaptors, you need to define MSGPACK_USE_BOOST. Adaptors require Boost Libraries.

MSGPACK_USE_DEFINE_MAP (since 1.2.0)

Default value: not defined.

When you define MSGPACK_USE_DEFINE_MAP, MSGPACK_DEFINE is aliased to MSGPACK_DEFINE_MAP and MSGPACK_BASE aliased to MSGPACK_BASE_MAP.

If you don't define MSGPACK_USE_DEFINE_MAP, MSGPACK_DEFINE is aliased to MSGPACK_DEFINE_ARRAY and MSGPACK_BASE aliased to MSGPACK_BASE_ARRAY.

See intrusive approach for more details.

MSGPACK_USE_LEGACY_NIL (since 1.4.0)

Default value: not defined

msgpack::type::nil is replaced with msgpack::type::nil_t to avoid conflict by #408.

nil is defined by system on some environment. See #368 and #406.

msgpack::type::nil is obsolete. You need to replace msgpack::type::nil with msgpack::type::nil_t.

However, if you want to continue using nil, define MSGPACK_USE_LEGACY_NIL. When you do so, msgpack::type::nil is defined as the typedef of msgpack::type::nil_t.

MSGPACK_USE_LEGACY_NAME_AS_FLOAT

Default value: not defined.

According to the msgpack format, that supports IEE 754 single or double precision floating-point number: https://github.com/msgpack/msgpack/blob/master/spec.md#float-format-family

msgpack-c provides the API to access to the float format family.

When you use msgpack::object, the type data member is msgpack::type::FLOAT in C++ and MSGPACK_OBJECT_FLOAT in C. The union field name is 'f64'. However they used have different names in the older versions of msgpack-c.

old name new name
msgpack::type::DOUBLE msgpack::type::FLOAT
MSGPACK_OBJECT_DOUBLE MSGPACK_OBJECT_FLOAT
dec f64

When you define the macro MSGPACK_USE_LEGACY_NAME_AS_FLOAT, both the old name and the new name are available. Otherwise only the new name is available.

See the following commit: https://github.com/msgpack/msgpack-c/commit/737e6703df2cad06cfb16e3e0e34a02ec5212c38

MSGPACK_USE_CPP03

Default value: not defined.

msgpack automatically detects C++ version (C++11 or C++03). If you define MSGPACK_USE_CPP03, msgpack uses C++03, even if the compiler is set to use C++11.

Use C++03:

g++ -std=c++03 test.cpp
g++ -std=c++11 -DMSGPACK_USE_CPP03 test.cpp

Use C++11:

g++ -std=c++11 test.cpp

MSGPACK_EMBED_STACK_SIZE

Default value: 32.

When msgpack format byte stream contains composite data, it would contain array of array of ... (N times).

C++

In C++, a stack of unpack context is implemented as a std::vector. MSGPACK_EMBED_STACK_SIZE hints the composite level.

msgpack reserves MSGPACK_EMBED_STACK_SIZE when using std::vector. If the msgpack format byte stream contains more than MSGPACK_EMBED_STACK_SIZE elements, std::vector is expanded. You can set the limit of the composite level. See limit size of elements.

C

In C, a stack of unpack context is implemented as an array. MSGPACK_EMBED_STACK_SIZE means the limit of the composite level. If N >= MSGPACK_EMBED_STACK_SIZE unpacking functions will return a parse error.

configuration (cmake)

MSGPACK_BUILD_EXAMPLES

Default value: ON

Build examples or not.

MSGPACK_BUILD_TESTS

Default value: If gtest is found then ON, otherwise OFF.

Build tests or not.

MSGPACK_GEN_COVERAGE

Default value: OFF

Generate coverage or not.

MSGPACK_CXX11 (C++ only)

Default value: OFF

Use C++11 or not.

MSGPACK_CXX17 (C++ only)

Default value: OFF

Use C++17 or not.