Re:Relive: 50 years of C, the good, the bad and the ugly
by Someone on Friday December 30, 2022 @01:26PM
(#34188103)
C is also relatively poor at providing “a way to define data structures which are really memory layouts”. Integer sizes (historically) and padding are implementation-defined, AFAIK bit fields are underspecified in that you cannot specify in what bits of a byte they end up.
[ Parent
| on HN ]
Re:Relive: 50 years of C, the good, the bad and the ugly
by thesuperbigfrog on Friday December 30, 2022 @01:50PM
(#34188431)
So true.
I wish that C had a more rich way to define struct layouts and low-level representations for integral types.
I really like how Ada does it:
https://en.wikibooks.org/wiki/Ada_Programming/Representation...
If you need to read or write specialized hardware registers, being able to define a data structure with a custom representation is very nice and can save significant time and effort.