[protobuf] g++ complains of incomplete type for pb Descriptor class

1,331 views
Skip to first unread message

petriborg

unread,
Apr 22, 2010, 10:02:51 AM4/22/10
to Protocol Buffers
Hi

I've created a very simple protobuf test to play with the reflection/
descriptors, but whenever I try to use the descriptor returned by
GetDescriptor() I get errors out of g++. What am I doing wrong?

I'm using Protobuf 2.3 on Linux

Code:
#include <string>
#include <iostream>
#include "test.pb.h"
namespace g = google::protobuf;
int main() {
std::cout << "START\n";
tsi::Time t;
const g::Descriptor* desc = t.GetDescriptor();
std::string s = desc->name();
std::cout << "END\n";
}

Proto:
package tsi;
message Time {
optional int64 milliseconds = 1; // Milliseconds since epoch
}

Error:
~/dev/pbdesc$ make all
LD_LIBRARY_PATH=/home/coonerp/dev/pbdesc/protobuf/lib /home/coonerp/
dev/pbdesc/protobuf/bin/protoc --cpp_out=. test.proto
g++ -o test.pb.o -I/home/coonerp/dev/pbdesc/protobuf/include -c
test.pb.cc
g++ -o main.o -I/home/coonerp/dev/pbdesc/protobuf/include -c main.cc
main.cc: In function ‘int main()’:
main.cc:16: error: invalid use of incomplete type ‘const struct
google::protobuf::Descriptor’
/home/coonerp/dev/pbdesc/protobuf/include/google/protobuf/
extension_set.h:52: error: forward declaration of ‘const struct
google::protobuf::Descriptor’
make: *** [all] Error 1

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

Henner Zeller

unread,
Apr 22, 2010, 1:03:26 PM4/22/10
to petriborg, Protocol Buffers
On Thu, Apr 22, 2010 at 07:02, petriborg <petr...@gmail.com> wrote:
> Hi
>
> I've created a very simple protobuf test to play with the reflection/
> descriptors, but whenever I try to use the descriptor returned by
> GetDescriptor() I get errors out of g++. What am I doing wrong?

you might want to include descriptor.h

petriborg

unread,
Apr 22, 2010, 1:08:59 PM4/22/10
to Protocol Buffers
Yep figured that out about 15 minutes after I sent the message :-/

Since the header file was using the Descriptor objects so much I
thought was included, didn't bother to check. Oops.

Thanks.
Pete

On Apr 22, 1:03 pm, Henner Zeller <henner.zel...@googlemail.com>
wrote:
> > For more options, visit this group athttp://groups.google.com/group/protobuf?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
> To post to this group, send email to prot...@googlegroups.com.
> To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/protobuf?hl=en.
Reply all
Reply to author
Forward
0 new messages