Hi Kenton, I am facing the same issue. In my case, I have multiple proto files created under the same package. When I add more than one proto file from the same package on to a project, each proto file is generating its own .pb.cc and .h files and each generated file has the below two methods. I need to include some of the generated .cc files to one of my projects which causes multiple definitions of the single function.
auto-generated functions causing "the function already has a body" issues are 1. protobuf_AssignDescriptorsOnce() 2. protobuf_RegisterTypes(const ::std::string&) Any help would be much appreciated. Regards, Abilash.G On Friday, April 2, 2010 at 1:02:29 AM UTC+5:30, Kenton Varda wrote: > > There shouldn't be any problem with omitting the package. The > declarations in your error message should not be appearing more than once. > I can't tell much from the error message. Can you investigate the > generated code and see whether it is actually double-declaring these > things? If so, please send us a sample. But my guess is that something is > weird about your environment, e.g. maybe your build system likes to > concatenate multiple source files and compile them at once (some build > systems do this), which doesn't work in the presence of anonymous > namespaces. > > On Mon, Mar 29, 2010 at 6:44 PM, Adam Schepis <[email protected]> wrote: > >> Having an error using code generated by protobuf (c++) version 2.2.0. >> I include a bunch of generated .pb.cc files generated from .proto >> files, none of which have packages defined. >> >> as a result i'm getting a bunch of strange errors: >> Error 1 error C2086: 'google::protobuf::GoogleOnceType `anonymous- >> namespace'::protobuf_AssignDescriptors_once_' : redefinition h:\src >> \project\trunk\src\trayicon\RegisterUserReq.pb.cc 57 TrayIcon >> Error 2 error C2084: function 'void `anonymous- >> namespace'::protobuf_AssignDescriptorsOnce(void)' already has a body h: >> \src\project\trunk\src\trayicon\RegisterUserReq.pb.cc 58 TrayIcon >> Error 3 error C2084: function 'void `anonymous- >> namespace'::protobuf_RegisterTypes(const std::string &)' already has a >> body h:\src\project\trunk\src\trayicon\RegisterUserReq.pb.cc 63 >> TrayIcon >> Error 4 error C3861: 'protobuf_AssignDescriptorsOnce': identifier >> not >> found h:\src\project\trunk\src\trayicon\RegisterUserReq.pb.cc 64 >> TrayIcon >> Error 5 error C3861: 'protobuf_AssignDescriptorsOnce': identifier >> not >> found h:\src\project\trunk\src\trayicon\RegisterUserReq.pb.cc 112 >> TrayIcon >> >> ...and the list goes on. >> >> My gut is telling me that this has something to do w/ the lack of >> packages, but i dont want to add them to the .protos because there are >> a lot of teams that depend on these .proto files and it would cause a >> lot of code changes for them to have to start using the new namespace >> in all the code where they use these messages. The other teams are >> still using protobuf 2.0.3 which apparently doesnt have this problem. >> >> any solutions to this or am i stuck? >> Thanks! >> >> -- >> 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. >> >> > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
