msgpack c ++无法写入管道

时间:2020-09-26 22:39:47

标签: c++ serialization msgpack

我已经通过网络阅读了很多有关msgpack的信息,但是找不到关于此问题的任何帮助。

#include<msgpack.hpp>

int main(){

 struct item {
    std::time_t currentTime;
    std::map<std::string, std::string> base;
    };


struct obj {
    std::string eventName;
    item item1;
    std::map<std::string, std::string> dateTime;    
};

obj obj1[1];
obj1[0].eventName = "TEMP_EVENT";
obj1[0].item1.base["Id"] = "6ba1ce80";
obj1[0].dateTime["TimeFormat"] = "DateTime";
std::stringstream buffer;
msgpack::pack(buffer, obj1);// this line is throwing the error
return 0;
        
}

看到以下错误,我正在使用msgpack-c库

left of '.msgpack_pack' must have class/struct/union 
       ~\packages\msgpack-c.0.5.9.1\build\native\include\msgpack\object.hpp(192):
   note: type is 'const obj [1]'
       ~\packages\msgpack-c.0.5.9.1\build\native\include\msgpack\object.hpp(155):
   note: while compiling class template member function
   'msgpack::v1::packer<Stream>
   &msgpack::v1::detail::packer_serializer<Stream,T>::pack(msgpack::v1::packer<Stream>
   &,const T (&))'
          with
        [
                  Stream=std::stringstream,
                   T=obj [1]
       ]

0 个答案:

没有答案
相关问题