Sujet : Re: Computer architects leaving Intel...
De : jgd (at) *nospam* cix.co.uk (John Dallman)
Groupes : comp.archDate : 15. Sep 2024, 15:41:52
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <memo.20240915154108.19028v@jgd.cix.co.uk>
References : 1
In article <
20240915154038.0000016e@yahoo.com>,
already5chosen@yahoo.com(Michael S) wrote:
Padding is another thing that should be Implementation Defined.
I.e. compiler should provide complete documentation of its padding
algorithms.
It is, and they do. I've used a lot of different compilers over the last
29 years, needing to know about padding for a DIY varargs, and I've never
had problems with finding out what the padding was.
It can usually be described quite briefly, by saying that all data types
are naturally aligned. The only variant of that I've encountered is on
32-bit x86 Linux and 32-bit POWER AIX where in both cases 8-byte doubles
were 4-byte aligned.
The C standard specifies that struct members shall be stored in memory in
the same order as they appear in the declaration. It does not specify
padding because the standard committee feel they need to allow C to work
on machines that are not byte-addressed or are otherwise weird.
In addition, some padding-related things can be defined by Standard
itself. Not in this particular case, but, for example, it could be
defined that when field of one integer type is immediately followed
by another field of integer type with the same or narrower width then
there should be no padding in-between.
That would be fine if you were willing to confine yourself to
byte-addressed machines.
John