#include <google/protobuf/io/coded_stream.h>
namespace google::protobuf::io
....
int fd = open("myfile", O_WRONLY);
ZeroCopyOutputStream* raw_output = new FileOutputStream(fd);
CodedOutputStream* coded_output = new CodedOutputStream(raw_output);
以上是跟随教程here ,但是当我编译时出现以下错误:
error C2061: syntax error : identifier 'io'
这里有什么问题吗?
更新
当我将上面的内容更改为 using namespace google::protobuf::io;
时,我收到一个新错误,指出符号 FileOutputStream
未定义,这是怎么回事?
最佳答案
为了回应关于为什么未声明 FileOutputStream 的更新问题...
我觉得你需要
#include <google/protobuf/io/zero_copy_stream_impl.h>
根据文档:
This file contains common implementations of the interfaces defined in zero_copy_stream.h which are only included in the full (non-lite) protobuf library.
These implementations include Unix file descriptors and C++ iostreams.
关于c++ - 使用 Google 的 protobuf 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3576044/