一、Visual Studio环境、Keil环境
#pragma pack (1)
二、Linux环境gcc
#define PACKED __attribute__((packed))
struct PACKED Gprs
{
unsigned short head;
unsigned char flag;
};
{
unsigned short head;
unsigned char flag;
};
typedef struct _UsrPhrase
{
char key;
int x;
} __attribute__((packed)) UsrPhrase;
struct __attribute__((packed)) GprsWeight
{
unsigned short head;
unsigned char flag;
unsigned char company;
unsigned short addr;
unsigned short driver;
unsigned int weight;
unsigned int time;
unsigned int package;
unsigned char checksum;
};
{
char key;
int x;
} __attribute__((packed)) UsrPhrase;
struct __attribute__((packed)) GprsWeight
{
unsigned short head;
unsigned char flag;
unsigned char company;
unsigned short addr;
unsigned short driver;
unsigned int weight;
unsigned int time;
unsigned int package;
unsigned char checksum;
};