I have the following example file structure:

.../someroot/foollib/foo.proto
.../someroot/barlib/bar.proto


foo.proto contains the following:
<code>
package ProtoC_Bug.Foo;

message Foo {
  required int32 stuff = 1;
}
</code>


bar.proto contains the following:
<code>
import "foolib/foo.proto";
package ProtoC_Bug.Bar;

message Bar {
  required ProtoC_Bug.Foo.Foo foo = 1;
  required int32 more_stuff = 2;
}
</code>


I run protoc thusly (cwd is in <someroot>, these complete without
errors):

  protoc.exe --proto_path=foolib --cpp_out=foolib foolib\foo.proto
  protoc.exe --proto_path=barlib --protopath=. --cpp_out=barlib barlib
\bar.proto


The generated foo.pb.h contains this (as expected):
<code>
...
namespace ProtoC_Buf {
namespace Foo {

void protobuf_AddDesc_foo_2eproto();
...
}
}
</code>

However, the generated bar.pb.cc uses that incorrectly (IMO):
<code>
...
void protobuf_AddDesc_bar_2eproto() {
  ...
  ::ProtoC_Bug::Foo::protobuf_AddDesc_foolib_2ffoo_2eproto();
  ...
}
...
</code>

I would expect that line to read (i.e. as it was declared in
foo.pb.h):
<code>
  ::ProtoC_Buf::Foo::protobuf_AddDesc_foo_2eproto();
</code>


If I change the contents of 'bar.proto' to omit the 'foolib' directory
on the import statement:
<code>
import "foo.proto";
package ProtoC_Bug.Bar;

message Bar {
  required ProtoC_Bug.Foo.Foo foo = 1;
  required int32 more_stuff = 2;
}
</code>

... and I change my command-line arguments for the generation of
barlib from:
  protoc.exe --proto_path=barlib --protopath=. --cpp_out=barlib barlib
\bar.proto
to:
  protoc.exe --proto_path=barlib --protopath=foolib --cpp_out=barlib
barlib\bar.proto

Then I get the expected output in bar.pb.cc.


The Language Guide documentation for Importing Definitions an example
containing a directory the .proto language (i.e. import "myproject/
other_protos.proto";), so I would expect "--protopath" argument(s) to
be supplied containing the parent directory of any imports with
subdirectories, as in my original example.

Is this behavior I'm observing expected, or a bug in protoc cpp
output?

Cheers,
David

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to