Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google::protobuf::io::FileOutputStream is not defined?

I'm trying to serialize multiple messages to a file using a protocol buffer - following the implementation shown here - but I am running into a problem whereby I can't access the FileOutputStream class as defined in <zero_copy_stream_impl.h>.

According to the API documentation, the FileOutputStream class is under the namespace google::protobuf::io - but the only definitions I can see under this namespace are CodedOutputStream, CodedInputStream, ZeroCopyOutputStream, and ZeroCopyInputStream.

Does anyone have any ideas on how to resolve this? FYI, I'm using Microsoft Visual Studio 2010 with protobuf-2.4.0a build. Here is a snippet of my code and the resulting error messages (Intellisense as well as compiler error):

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);

warning C4996: '_open': This function or variable may be unsafe. Consider using _sopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

IntelliSense: expected a type specifier

error C2061: syntax error : identifier 'FileOutputStream'

error C2039: 'FileOutputStream' : is not a member of 'google::protobuf::io'

like image 517
KnightsValour Avatar asked Oct 12 '25 18:10

KnightsValour


1 Answers

It seems that my code explicitly required this:

#include <google/protobuf/io/zero_copy_stream_impl.h>

I figured it would be included by default, but apparently that's not the case. Thanks to Kenton Varda for pointing this out.

like image 167
KnightsValour Avatar answered Oct 16 '25 02:10

KnightsValour