我试图使用协议缓冲区将多条消息序列化到一个文件中--遵循显示的这里实现--但我遇到了一个问题,无法访问<zero_copy_stream_impl.h>中定义的FileOutputStream类。
根据API文档,FileOutputStream类位于名称空间google::protobuf::io下,但我在这个名称空间中看到的唯一定义是CodedOutputStream、CodedInputStream、ZeroCopyOutputStream和ZeroCopyInputStream。
有没有人知道如何解决这个问题?FYI,我使用2010与protobuf-2.4.0a构建。下面是我的代码片段和由此产生的错误消息(Intellisense以及编译器错误):
int outfd = _open(fileName.c_str(), _O_CREAT | _O_BINARY | _O_APPEND | _O_WRONLY);
google::protobuf::io::ZeroCopyOutputStream *output = new google::protobuf::io::FileOutputStream(outfd);警告C4996:'_open':此函数或变量可能不安全。考虑使用_sopen_s代替。若要禁用弃用,请使用_CRT_SECURE_NO_WARNINGS。
IntelliSense:预期的类型说明符
错误C2061:语法错误:标识符'FileOutputStream‘
错误C2039:'FileOutputStream‘:不是'google::protobuf::io’的成员
发布于 2014-07-23 14:40:47
我的代码似乎明确要求这样做:
#include <google/protobuf/io/zero_copy_stream_impl.h>
我想默认情况下会包括在内,但显然不是这样的。感谢肯顿·瓦尔达指出了这一点。
https://stackoverflow.com/questions/24890944
复制相似问题