Joined: Thu Jan 07, 2016 12:29 pm Posts: 5
|
Programmer may want to align the address of structure to 8 bytes. It lists two ways below: 1.Use an option __attribute__((aligned(8)))before statement of a structure. For example: typedef __attribute__((aligned(8))) struct{ char a; char a1; short b; short f; int c; int d; char a2; //__attribute__((aligned(8))) int d;
} typedef_str;
2. Make sure that one of the variable in the structure is double type or 8 byte alignment. For example: typedef struct{ char a; char a1; short b; short f; int c; double d; char a2;
} typedef_str; or typedef struct{ char a; char a1; short b; short f; int c; int d; char a2; __attribute__((aligned(8))) int d;
} typedef_str;
|
|