shiyilei / protobuf-c

Automatically exported from code.google.com/p/protobuf-c
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

uint64 problems on 32 bit platforms #59

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I didn't see another issue about this -- sorry if this is a double post.  Issue 
is include uint64s before a float field seems to cause the float to be unpacked 
incorrectly on 32-bit platforms.

What steps will reproduce the problem?
In attached example:
 1. "value" should be 12.0 after the encode-decode round trip; instead it's 0.0 on 32-bit platforms.  It works correctly on 64-bit platforms.
 2. Changing the "timestamp" field to a uint32 "fixes" the problem
 3. I have verified that the bytes generated by the library are the same on 32- and 64-bit platforms so the problem is likely in the deserialization routine.

What version of the product are you using? On what operating system?
protobuf-2.4.1, protobuf-c-0.15

gcc 4.4.1-4ubuntu9 on 32-bit
gcc Debian 4.3.2-1.1 on 64-bit

Original issue reported on code.google.com by sdh...@gmail.com on 2 May 2011 at 8:20

Attachments:

GoogleCodeExporter commented 8 years ago
on a 32-bit platform, %lu is for printing 32-bit integers.  on line 55,
Use %llu:
       printf("timestamp: %llu val: %f\n",
or (ugly but most portable):
       printf("timestamp: %"PRId64" val: %f\n",

Original comment by lahike...@gmail.com on 10 May 2011 at 5:56

GoogleCodeExporter commented 8 years ago
Whoops, PRId64 is for signed-int64; it should be PRIu64 instead...

Original comment by lahike...@gmail.com on 10 May 2011 at 5:58

GoogleCodeExporter commented 8 years ago
I believe with my correction this is fine.  Please reopen if more problems are 
encountered.

Original comment by lahike...@gmail.com on 14 May 2011 at 1:09