Optimal structure field ordering

Steven Ryan smryan at garth.UUCP
Sun Jun 26 05:53:37 AEST 1988


In article <163 at navtech.uucp> mark at navtech.uucp (Mark Stevans) writes:
>                                        The easy way to save space on almost
>all C implementations is to sort your structure fields in order of descending
>size of the field type.

(Not being a C expert, I don't know if this true.)  A nice language definition
will say you can define fields but doesn't say what order they are allocated. It
would be better if the compiler can sort the fields to optimise access and
balance space/time. In this way you can write the structures as it makes sense
and not worry about dinking it for a particular machine.



More information about the Comp.lang.c mailing list