ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Вторник
21 мая
57499 Топик полностью
scum (27.04.2006 11:54, просмотров: 1) ответил VAI на Может кто, знающий С прокоментирует?
В iso/iec 9899:1999 указано что компилер не может поменять местами поля структуры, а вот проредить их может запросто. Так что в общем случае всё-таки нельзя гарантировать как структура отляжет в памяти. Выравнивание полей как правило рулится прагмами, кот орые описаны в доке на конкретный компилер. 12 Each non-bit-field member of a structure or union object is aligned in an implementation defined manner appropriate to its type. 13 Within a structure object, the non-bit-field members and the units in which bit-fields reside have addresses that increase in the order in which they are declared. A pointer to a structure object, suitably converted, points to its initial member (or if that member is a bit-field, then to the unit in which it resides), and vice versa. There may be unnamed padding within a structure object, but not at its beginning.