Gast
#640007
Hallo!
Ich bin gerade dabei, mir eine Datenstruktur zu basteln, und hätte gerne
ein 2-byte-aligment für die einzelnen Elemente, d.h.:
struct foo {
uint16_t a;
uint8_t b;
uint8_t c;
uint8_t d;
uint16_t e;
};
offsetof(foo, a) == 0;
offsetof(foo, b) == 2;
offsetof(foo, c) == 3;
offsetof(foo, d) == 4;
offsetof(foo, e) == 6; (anstatt 5 ohne aligment).
Unter normalen umständen würde man die Definition in ein
#pragma pack(push,2)
..
#pragma pack(pop)
verpacken, der avr-gcc meldet jedoch:
warning: ignoring #pragma pack
Ein nachgestelltes "__attribute__ ((aligned (2)))" funktioniert auch
nicht:
warning: alignment of 'foo' is greater than maximum object file
alignment. Using 1
Gibt's noch andere Möglichkeiten (abgesehen von manuell eingefügtem
padding?)