ByteSize() with in Google protocol buffer

2.2k views Asked by At

now I develop the test code using GPB in qnx as follows:

Offer_event Offer;
string a = "127.0.0.7";

Offer.set_ipaddress(a);
Offer.set_port(9000);

      BufSize = Offer.ByteSize();

Length_message = BufSize + Message_Header_Size;
Message->PayloadLength_of_Payload = BufSize;
PayloadBuffer = new char[BufSize];
Offer.SerializeToArray(PayloadBuffer, BufSize);

in that case, I met some errors. but I cannot understand it.

that error is as follows:

#0  std::string::size (this=0xcd21c0)
at /home/builder/hudson/650-gcc-4.4/svn/linux-x86-o-ntoarmeabi/arm-unknown-nto-qnx6.5.0eabi/pic/libstdc++-v3/include/bits/basic_string.h:624
624     /home/builder/hudson/650-gcc-4.4/svn/linux-x86-o-ntoarmeabi/arm-unknown-
nto-qnx6.5.0eabi/pic/libstdc++-v3/include/bits/basic_string.h: No such file or d
irectory.
in /home/builder/hudson/650-gcc-4.4/svn/linux-x86-o-ntoarmeabi/arm-unkno
wn-nto-qnx6.5.0eabi/pic/libstdc++-v3/include/bits/basic_string.h
(gdb) bt
#0  std::string::size (this=0xcd21c0)
at /home/builder/hudson/650-gcc-4.4/svn/linux-x86-o-ntoarmeabi/arm-unknown-n
to-qnx6.5.0eabi/pic/libstdc++-v3/include/bits/basic_string.h:624
#1  0x0067d6b0 in google::protobuf::internal::WireFormatLite::StringSize ()
#2  0x0063ecd0 in Offer_event::ByteSize ()
#3  0x00404f18 in AnalysisCmdC_Actor::TestGPB ()

from C:/QNX650/target/qnx6/armle-v7/lib/libc.so.3
#11 0x0004201a in ?? ()
Cannot access memory at address 0x0
Current language:  auto; currently c++
(gdb)

I don't know why the ByteSize has a problem. If i delete the string part, it works well. I think usage of string is problem.

what's the problem?

0

There are 0 answers