Issue 420 in protobuf: code generation problem when using namespaces and import from a root directory

27 views
Skip to first unread message

prot...@googlecode.com

unread,
Sep 19, 2012, 9:41:14 AM9/19/12
to prot...@googlegroups.com
Status: New
Owner: liuj...@google.com
Labels: Type-Defect Priority-Medium

New issue 420 by pierre.g...@free.fr: code generation problem when using
namespaces and import from a root directory
http://code.google.com/p/protobuf/issues/detail?id=420

What steps will reproduce the problem?
1. create directory ns1 and subdirectory ns2 (ex <project_path>\ns1\ns2)
2. create a first proto file with a message within package ns1.ns2; (ex
person.proto)
3. create a second proto file in the same package ns1.ns2; and add
import "ns1/ns2/First.proto"; + a message using the message declared in
step 2. (ex addressbook.proto)
4. for each proto file generate code using the command: protoc
-I="<project_path>" -I=. --cpp_out=. <file_name>.proto

What is the expected output? What do you see instead?
Generated code should compile but instead there is a problem with names of
few generated functions used in generated outer classes.
Ex:
In file addressbook.pb.cc, function void
protobuf_AddDesc_addressbook_2eproto() calls
function ::ns1::ns2::protobuf_AddDesc_ns1_2fns2_2fPerson_2eproto() instead
of ::ns1::ns2::protobuf_AddDesc_Person_2eproto() declared in person.pb.h

What version of the product are you using? On what operating system?
protoc --version --> libprotoc 2.4.1
Tested on Windows XP and Windows Seven

Please provide any additional information below.
Full example available in attachment

Attachments:
ns1.zip 11.4 KB

prot...@googlecode.com

unread,
Dec 3, 2012, 6:20:37 PM12/3/12
to prot...@googlegroups.com
Updates:
Status: WorkingAsIntended

Comment #1 on issue 420 by xiaof...@google.com: code generation problem
when using namespaces and import from a root directory
http://code.google.com/p/protobuf/issues/detail?id=420

You should be able to compile your code with the following command (after
rename "Person.proto" to "person.proto"):
~$ protoc --cpp_out=. -I. ns1/ns2/addressbook.proto ns1/ns2/person.proto

prot...@googlecode.com

unread,
Dec 7, 2012, 8:00:45 AM12/7/12
to prot...@googlegroups.com

Comment #2 on issue 420 by techedud...@gmail.com: code generation problem
when using namespaces and import from a root directory
http://code.google.com/p/protobuf/issues/detail?id=420

This example generates broken code as reported. Please take another look

prot...@googlecode.com

unread,
Dec 7, 2012, 2:06:40 PM12/7/12
to prot...@googlegroups.com

Comment #3 on issue 420 by xiaof...@google.com: code generation problem
when using namespaces and import from a root directory
http://code.google.com/p/protobuf/issues/detail?id=420

Please use the command line I gave in comment #1 to compile the proto file.

Reply all
Reply to author
Forward
0 new messages