私は2つの構造を持っています:
Struct _size1 {
union{
short a;
struct {
char b;
char c;
}d;
struct {
char x;
char y;
}z;
};
union{
short a1;
struct {
char b1;
char c1;
}d1;
struct {
char x1;
char y1;
}z1;
};
}size1;
と:
Struct _size2 {
short num; //2 bytes
short num2; //2 bytes
short num3; //2 bytes
size1 st_size; //4 bytes
}size2;
sizeof(size1) = 4; sizeof(size2) = 12;
取得しようとしているサイズは size2 で 10 です。
num3 と st_size の間に 2 バイトのパディングを追加しています。 Microblaze コンパイラはプラグマ パックをサポートしていません。
属性((packed))を使用しようとしていますが、成功していません...
Struct _size2 {
short num; //2 bytes
short num2; //2 bytes
short num3; //2 bytes
size1 st_size; //4 bytes
}size2 __attribute__((packed));
何が悪いのか、これがこのように機能するのかどうかはわかりません。
ありがとう