PDA

Click to See Complete Forum and Search --> : Wird...


Chris
Apr 5th, 2002, 12:41 AM
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


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;

kedaman
Apr 5th, 2002, 06:45 AM
MTUid is aligned after a 3 bytes gap, 2 extra bytes are wasted after UnitStatus, move Event downmost and see if it helps

Chris
Apr 6th, 2002, 07:45 PM
:cool: CornedBee, now I know where the extra 5 bytes come from :)

Thx a lot.

regards,
Chris.C