Liste des Groupes | Revenir à c arch |
In article <20240915154038.0000016e@yahoo.com>, already5chosen@yahoo.comIt is better to say types are naturally aligned up to a maximum appropriate for the architecture (usually the width of general-purpose registers and/or pointers). Then there are far fewer exceptions.
(Michael S) wrote:
Padding is another thing that should be Implementation Defined.It is, and they do. I've used a lot of different compilers over the last
I.e. compiler should provide complete documentation of its padding
algorithms.
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 inIt specifies that there can be padding between members, and members need to be aligned, so it gives the minimum padding (though the alignment requirements are implementation-defined). But it gives no maximum padding, AFAIK.
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.
There would not be padding between one integer type and another member of the same or smaller integer type, unless you have a very odd architecture or niche features (like, say, an int24_t with 1-byte alignment followed by an int16_t with 2-byte alignment).In addition, some padding-related things can be defined by StandardThat would be fine if you were willing to confine yourself to
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.
byte-addressed machines.
Les messages affichés proviennent d'usenet.