i960 Processor Compiler User's Guide
7-36
7
s.b would be placed at offset 2 from the base of s; sizeof(struct s)
would be 6 under gcc960’s mic-compat (#pragma align 1) and 8 under
default alignment (
#pragma align 16). The formal alignment
requirement of
struct s would be 2 under mic-compat and 8 under
default alignment.
The examples in the tables below all use the following sample structure:
typedef struct {
char m1;
short m2;
double m3;
char m4;
int m5;
} s0;
Table 7-2 Example Offset Values
Normal i960
Rules
gcc960 Driver’s
#pragma pack 2
offset_of(s0, m1) 0x0
0x0
offset_of(s0, m2) 0x2
0x2
offset_of(s0, m3) 0x8
0x4
offset_of(s0, m4) 0x10
0xc
offset_of(s0, m5) 0x14
0xe
sizeof(s0) 0x20
0x20
#pragma pack 1
#pragma pack 2
#pragma align 2
offset_of(s0, m1) 0x0
0x0
offset_of(s0, m2) 0x1
0x2
offset_of(s0, m3) 0x3
0x4
offset_of(s0, m4) 0xb
0xc
offset_of(s0, m5) 0xc
0xe
sizeof(s0) 0x10
0x12