On Thu, Apr 5, 2012 at 01:03, G. <[email protected]> wrot> Hi, > > Thanks for responding. This is exactly the way I access the fields. > > Code snippet: > ... > b.set_billableseat("Mediamind"); > b.set_category(5); > b.set_clickthroughurl("http://www.ynet.co.il"); > b.set_creativeid("ab15a"); > ... > I walked through this with the debugger. When billableseat is set, > Clickthroughurl and creativeId both become "Mediamind" as well. Same > with clickthroughUrl and creativeId - setting each one of them turns > all 3 fields the same value. Only setting Category didn't affect > anything except category.
What compiler are you using ? Protocol buffers definitely don't behave this way, so only a very broken compiler or something peculiar in your memory management or other setup can cause this. (IIRC, default values in protobufs share a const instance (in this case: the empty string) for memory reasons, so you would see the same address for the default values, but this is of course disengaged whenever a value is set.) If you just create a simple protocol buffer with two string fields and a simple main() function: do you get the same behavior ? -h > Thanks, > > G. > > > > On Apr 4, 7:45 pm, Jeremiah Jordan <[email protected]> wrote: >> How are you setting the data? >> You should be using something like: >> bid.set_HtmlSnippet("Stuff"); >> and >> std::string html = bid.HtmlSnippet(); >> >> See:https://developers.google.com/protocol-buffers/docs/reference/cpp/goo... >> >> >> >> >> >> >> >> On Wednesday, April 4, 2012 7:25:15 AM UTC-5, G. wrote: >> >> > Hi all, >> >> > I am using protobuf 2.4.1, and I encountered a weird issue: >> >> > I created the following .proto file: >> >> > message Auction { >> > // Bid request id >> > required bytes Id = 1; >> > optional bytes Ip = 2; >> > required int32 adId = 3; >> > required int32 adHeight = 4; >> > required int32 adWidth = 5; >> > optional string domain = 6; >> > optional string country = 7; >> > optional string region = 8; >> > required string exchangeUserId = 9; >> > optional string pageUrl = 10; >> > optional int32 publisherId = 11; >> > optional int32 timezoneOffset = 12; >> > optional string userAgent = 13; >> > required string identifier = 14; >> > } >> >> > message Bid { >> > // Bid request Id >> > required bytes Id = 1; >> > required int32 processingTime = 2; >> > required int32 adId = 3; >> > required float bid = 4; >> > required int32 advertiserId = 5; >> > required string creativeId = 6; >> > required string billableSeat = 7; >> > required int32 category = 8; >> > required int32 vendorType = 9; >> > required int32 strategyId = 10; >> > required string clickthroughUrl = 11; >> > required string HtmlSnippet = 12; >> > } >> >> > It compiles fine with protoc.exe. >> >> > However, when I tried assigning the fields, I noticed the following >> > phenomenon: the fields id, billableseat and htmlsnippet in Bid >> > structure share the same address! When one is assigned, so are the >> > other two. >> >> > What am I doing wrong? Has anyone encountered such a thing before? >> >> > Thanks, >> >> > G. > > -- > 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 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.
