- 论坛徽章:
- 0
|
原帖由 zx_wing 于 2009-5-18 10:04 发表 ![]()
当然有关系。如果ABI规定padding在reply之后data之前,结果就完全不一样
据我所知,结构体内的域之间的padding不是ABI规定的,而是编译器的具体实现。
C89:
Each non-bit-field member of a structure or union object is aligned
in an implementation-defined manner appropriate to its type.
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
cast, 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
therefore be unnamed holes within a structure object, but not at its
beginning, as necessary to achieve the appropriate alignment.
The size of a union is sufficient to contain the largest of its
members. The value of at most one of the members can be stored in a
union object at any time. A pointer to a union object, suitably cast,
points to each of its members (or if a member is a bit-field, then to
the unit in which it resides), and vice versa.
There may also be unnamed padding at the end of a structure or
union, as necessary to achieve the appropriate alignment were the
structure or union to be a member of an array. |
|