Git Product home page Git Product logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on May 27, 2024
Hi,

What compiler are you using?

John

Original comment by [email protected] on 14 Jun 2012 at 5:00

from moveme.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 27, 2024
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 [email protected] on 14 Jun 2012 at 5:33

from moveme.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.