Results 1 to 3 of 3

Thread: Wird...

  1. #1

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Wird...

    I encounter this in my current development and hope someone can explain more abt it

    Below is a structure that i define in my application. By reference to the MSDN and I get 67 Bytes with reference to the individual data type. But once, i use the sizeof() function, i get 72 bytes. Where the extra 5 bytes come from?

    So, in future, should i use the sizeof function? or

    PHP Code:
    typedef struct tagGPS
    {
        
    double TOW;                    // 8 bytes
        
    double Lat;                    // 8 bytes
        
    double Lon;                    // 8 bytes
        
    int Alt;                    // 4 bytes
        
    int Speed;                    // 4 bytes
        
    int ClimbRate;                // 4 bytes
        
    int WeekNum;                // 4 bytes
        
    double Direction;            // 8 bytes
        
    int Mode;                    // 4 bytes
        
    int DOP;                    // 4 bytes
        
    int NumSat;                    // 4 bytes
        
    unsigned char Event;        // 1 bytes
        
    unsigned short MTUid;        // 2 bytes
        
    unsigned short GPIO;        // 2 bytes
        
    unsigned short UnitStatus;    // 2 bytes
                                    //========
                                    //67 bytes 
    }GPS

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    MTUid is aligned after a 3 bytes gap, 2 extra bytes are wasted after UnitStatus, move Event downmost and see if it helps
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up

    CornedBee, now I know where the extra 5 bytes come from

    Thx a lot.

    regards,
    Chris.C

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width