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;
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;