バイトの配置の2つの方法
1082 ワード
#include
#include
#include
#include
#include
#include
#include
#pragma pack (1)
struct data
{
int i;
int j;
int k;
char c;
};
#pragma pack ()
#pragma pack (4)
struct data2
{
int i;
int j;
int k;
char c;
};
#pragma pack ()
struct data3
{
int i;
int j;
int k;
char c;
} __attribute__((aligned(4)));
struct data4
{
int i;
int j;
int k;
char c;
}__attribute__((packed));
int main()
{
struct data dat;
struct data2 dat2;
struct data3 dat3;
struct data4 dat4;
int datt = sizeof(dat);
printf("sizeof(dat) = %d
", sizeof(dat));
printf("sizeof(dat2) = %d
", sizeof(dat2));
printf("sizeof(dat3) = %d
", sizeof(dat3));
printf("sizeof(dat4) = %d
", sizeof(dat4));
return 0;
}