Open GoogleCodeExporter opened 9 years ago
Hi,
What compiler are you using?
John
Original comment by j...@johnmccutchan.com
on 14 Jun 2012 at 5:00
This is on iOS (both ARM and x86 simulator) using XCode 4.2 with LLVM 3.0. The
UDP network packet received from the server was 2132 bytes. The
sizeof(MoveServerPacket) (with 32bit compile) before my fix was 2100.
Further testing by building with different compilers and 32 vs. 64 bit shows
even more issues.
/* main.c */
include "moveclient.h"
#include <stdio.h>
int main(int argc, char **argv)
{
printf("Size is %lu\n", sizeof(MoveServerPacket));
return 0;
}
========
Mac OS X 10.6.8
$ gcc --version
i686-apple-darwin10-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658)
(LLVM build 2336.1.00)
$ gcc -m32 -o main main.c
$ ./main
Size is 2100
$ gcc -m64 -o main main.c
$ ./main
Size is 2152
Non LLVM gcc, same results:
$ gcc-4.0 --version
i686-apple-darwin10-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5494)
$ gcc-4.0 -m32 -o main main.c
$ ./main
Size is 2100
$ gcc-4.0 -m64 -o main main.c
$ ./main
Size is 2152
Obviously, you don't want there to be any size differences in your struct when
you are overlaying it on top of a fixed sized network packet without more
fine-grained deserialization.
By applying __attribute__((packed)) to every struct and padding the
MoveImageState with two additional unsigned chars to round that up, only then
did the 32bit and 64bit compiles come up with the same number (2100 bytes).
However, I am receiving 2132 byte packets from the PS3 move.me server and only
by adding the 8byte padding in the MoveState struct is the resulting data
interpreted correctly.
What are other people seeing with different platforms with regards to the
struct and recv'd packet sizes?
Original comment by esse...@gmail.com
on 14 Jun 2012 at 5:33
Original issue reported on code.google.com by
esse...@gmail.com
on 14 Jun 2012 at 4:31