Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msgpack::v1::adaptor::convert<wchar_t,void>编译错误 #1068

Open
cbccy opened this issue May 4, 2023 · 1 comment
Open

msgpack::v1::adaptor::convert<wchar_t,void>编译错误 #1068

cbccy opened this issue May 4, 2023 · 1 comment

Comments

@cbccy
Copy link

cbccy commented May 4, 2023

第一次尝试用msgpack,是否有人遇到过编译测试demo时的头文件重定义错误:
msgpack\include\msgpack/v1/adaptor/int.hpp(153): error C2766: 显式专用化;已定义“msgpack::v1::adaptor::convert<wchar_t,void>”
msgpack\include\msgpack/v1/adaptor/int.hpp(107): note: 参见“convert<unsigned short,void>”的前一个定义

测试demo如下:
`#include <msgpack.hpp>
#include
#include
#include

int main()
{
msgpack::type::tuple<int, bool, std::string> src(1, true, "example");

// serialize the object into the buffer.
// any classes that implements write(const char*,size_t) can be a buffer.
std::stringstream buffer;
msgpack::pack(buffer, src);

// send the buffer ...
buffer.seekg(0);

// deserialize the buffer into msgpack::object instance.
std::string str(buffer.str());

msgpack::object_handle oh =
    msgpack::unpack(str.data(), str.size());

// deserialized object is valid during the msgpack::object_handle instance is alive.
msgpack::object deserialized = oh.get();

// msgpack::object supports ostream.
std::cout << deserialized << std::endl;

// convert msgpack::object instance into the original type.
// if the type is mismatched, it throws msgpack::type_error exception.
msgpack::type::tuple<int, bool, std::string> dst;
deserialized.convert(dst);

// or create the new instance
msgpack::type::tuple<int, bool, std::string> dst2 =
    deserialized.as<msgpack::type::tuple<int, bool, std::string> >();

return 0;

}`

@gwankyun
Copy link

#include <msgpack.hpp>

前面加上

#define MSGPACK_USE_CPP03

或者用C++20標準試試。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants