Skip to content

v1_1_cpp_configure

Takatoshi Kondo edited this page Jan 21, 2016 · 9 revisions

configuration

MSGPACK_USE_BOOST (since 1.2.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. The adaptors requires the Boost Libraries.

MSGPACK_USE_DEFINE_MAP (since 1.2.0)

Default value: not defined

When you define MSGPACK_USE_DEFINE_MAP, MSGPACK_DEFINE is an alias of MSGPACK_DEFINE_MAP and MSGPACK_BASE is an alias of MSGPACK_BASE_MAP. If you doesn't defined, MSGPACK_DEFINE is an alias of MSGPACK_DEFINE_ARRAY and MSGPACK_BASE is an alias of MSGPACK_BASE_ARRAY. See intrusive approach.

MSGPACK_DISABLE_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. You need to replace msgpack::type::nil with msgpack::type::nil_t in your codes. However, you might want to continue to use nil. If MSGPACK_DISABLE_LEGACY_NIL is NOT defined, msgpack::type::nil is defined as the typedef of msgpack::type::nil_t. However, msgpack::type::nil is obsolete. It will be removed in the version 2.0.0. Please define MSGPACK_DISABLE_LEGACY_NIL to prepare the version 2.0.0.

MSGPACK_DISABLE_LEGACY_CONVERT (since 1.4.0)

Default value: not defined

msgpack::object::convert(T*) is removed to solve #399. You need to use msgpack::object::convert(T&). If MSGPACK_DISABLE_LEGACY_CONVERT is NOT defined, msgpack::object::convert(T*) is removed. msgpack::object::convert(T*) is obsolete. It will be removed in the version 2.0.0. Please define MSGPACK_DISABLE_LEGACY_CONVERT to prepare the version 2.0.0 and update your code as follows:

Replace

int i;
obj.convert(&i);

with

int i;
obj.convert(i);

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, 'type' data member is 'msgpack::type::FLOAT' in C++ and 'MSGPACK_OBJECT_FLOAT' in C. The union field name is 'f64'. But it used to have different names.

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 is automatically detected C++ version (C++11 or C++03). When you define MSGPACK_USE_CPP03, msgpack use C++03 stuff even if the compiler is C++11.

Use C++03 stuff:

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

Use C++11 stuff:

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 means the hint of the composite level. msgpack reserves MSGPACK_EMBED_STACK_SIZE elements of the std::vector. If the msgpack format byte stream contains over 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 return parse error.

Clone this wiki locally