C++11でmsgpack-cを利用するときはMSGPACK_DISABLE_LEGACY_NILする
msgpack-c
error: expected unqualified-id typedef nil_t nil;
msgpack/msgpack-cのcpp-2.0.0を利用. そのまま読み込むと以下のようなエラーを吐く.
In file included from /path/to/msgpack-c/include/msgpack.hpp:18: In file included from /path/to/msgpack-c/include/msgpack/type.hpp:13: In file included from /path/to/msgpack-c/include/msgpack/adaptor/nil.hpp:13: In file included from /path/to/msgpack-c/include/msgpack/adaptor/nil_decl.hpp:13: /path/to/msgpack-c/include/msgpack/v1/adaptor/nil_decl.hpp:28:15: error: expected unqualified-id typedef nil_t nil; ^ /usr/include/MacTypes.h:92:19: note: expanded from macro 'nil' #define nil nullptr ^
環境は
対処法
該当箇所見た感じ,MSGPACK_DISABLE_LEGACY_NIL
をつけてあげれば回避できそう.
#if !defined(MSGPACK_DISABLE_LEGACY_NIL) typedef nil_t nil; #endif // !defined(MSGPACK_DISABLE_LEGACY_NIL)
CMakeであれば以下のコードをCMakeLists.txt
に追記してあげれば問題なく動く.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMSGPACK_DISABLE_LEGACY_NIL")
雑記
v1/adaptor
namespaceで怒られてるのがちょっと不思議なので,どっかでなんか間違ったのかもしれない.