Not if you do it well. Plan 9 did it and it was easy.

The notion that the struct layout must correspond to the hardware device's layout is about as non-portable as thinking can get.

-rob


On Wed, Mar 5, 2025 at 8:27 AM Greg A. Woods <woods@robohack.ca> wrote:
At Tue, 04 Mar 2025 06:37:56 +0000, Lars Brinkhoff <lars@nocrew.org> wrote:
Subject: [TUHS] Re: Any UNIX With No C In Userland?
>
> I NEVER EVER use C structs or bit fields for this.  I get the raw octets
> (or whatever the byte size is), and shift and mask accordingly to get
> the data fields.

Marshalling data in or out byte by byte is of course safe and is
definitely the most portable way, and one can of course still read or
write "record"-length amounts of bytes at one time (or multiples of
records).  It just can be a little more tedious.

--
                                        Greg A. Woods <gwoods@acm.org>

Kelowna, BC     +1 250 762-7675           RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>     Avoncote Farms <woods@avoncote.ca>