At Mon, 3 Mar 2025 22:31:13 +1100, Peter Yardley <peter.martin.yardley(a)gmail.com>
wrote:
Subject: [TUHS] Re: Any UNIX With No C In Userland?
Problems I have with C as a systems language is there is no
certainty about representation of a structure in memory and hence
when it is written to disk.
That might be true for some nit-pick-ity "Standard C", but it isn't true
for most real implementations, at least in the realm of 'hosted'
implementations. Real implementations do after all have to interface
with real hardware.
In fact it's not impossible, or even really hard, to define a struct,
even with bitfields, that can be "portably" compiled for a number of
different architectures and platforms, including with different word
sizes and endianness and which will map directly onto an external binary
data representation. It can get a bit ugly to look at, but it works.
Between the compiler manual and the ABI manual it _should_ all be quite
clear how to do it.
Of course "Standard C" has only got worse as it has morphed along the
way, growing increasingly thorny with more instead of less "Undefined
Behaviour".
--
Greg A. Woods <gwoods(a)acm.org>
Kelowna, BC +1 250 762-7675 RoboHack <woods(a)robohack.ca>
Planix, Inc. <woods(a)planix.com> Avoncote Farms <woods(a)avoncote.ca>