Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Header include path in files generated by `protoc`

When I call protoc like this

protoc --cpp_out=. path/to/test.proto

the files

  • path/to/test.pb.cc and
  • path/to/test.pb.h

are generated which is what I want. But, since the cc needs the h, the h is included like this

#include "path/to/test.pb.h"

which is not what I want. The background is that my build tool (scons) calls protoc from the project's root and not from the directory which includes the source files. I found no obvious option in the manpage or the help text.

So my next idea was to consider this as "correct" and adjust my build system, but: The two files are siblings in the directory tree, so when one includes the other, no path is needed. Even compiling by hand fails.

Can someone help me with that?

like image 538
wal-o-mat Avatar asked Jan 16 '13 09:01

wal-o-mat


People also ask

What is protoc file?

protoc is a compiler for protocol buffers definitions files. It can can generate C++, Java and Python source code for the classes defined in PROTO_FILE.

What does protoc compiler do?

proto files), the code that the proto compiler generates to interface with data, language-specific runtime libraries, and the serialization format for data that is written to a file (or sent across a network connection).

What is the difference between protoc and Protobuf?

"protobuf" or "protocol buffers" is the name of a serialization format and/or associated tooling. ". proto" is a schema DSL used for describing the messages you plan to use in your application - it is text based.

What does Protobuf generate?

Oneof Fields For a oneof field, the protobuf compiler generates a single field with an interface type isMessageName_MyField . It also generates a struct for each of the singular fields within the oneof. These all implement this isMessageName_MyField interface.


1 Answers

Doing find-replace on generated files is most likely easier than reorganization of your build system (use sed command on Linux/unix).

like image 79
pafinde Avatar answered Sep 20 '22 17:09

pafinde