4 ms·
No, in C struct members must be allocated in the order in which they are declared. C99 §6.2.5 says: A structure type describes a sequentially allocated no
by caf 13y ago
No, in C struct members must be allocated in the order in which they are declared. C99 §6.2.5 says:
A structure type describes a sequentially allocated
nonempty set of member objects (and, in certain
circumstances, an incomplete array), each of which
has an optionally specified name and possibly
distinct type.
and §6.5.8 says:
If the objects pointed to are members of the same
aggregate object, pointers to structure members
declared later compare greater than pointers to
members declared earlier in the structure,…
- mansr 13y agoWhat the language standard does not specify (and is very explicit about not doing) is padding between struct members, if any. However, the ABI spec for the compilation target details exactly how a struct must be laid out. If this were not the case, libraries could not work.