Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: John Ames Newsgroups: comp.os.linux.misc,alt.folklore.computers Subject: Re: naughty Python Date: Fri, 2 Jan 2026 08:49:25 -0800 Organization: A noiseless patient Spider Lines: 18 Message-ID: <20260102084925.000040b5@gmail.com> References: <79ScnZHy-uXnP8n0nZ2dnZfqnPadnZ2d@giganews.com> <4oycne7Wk4RQ6sj0nZ2dnZfqnPidnZ2d@giganews.com> <10j48fv$2t1h9$12@dont-email.me> <10j5qgf$3etcd$6@dont-email.me> <10j60bb$3hhps$1@dont-email.me> <10j6n9s$3q8au$2@dont-email.me> <10j71fr$3rnk5$1@paganini.bofh.team> <10j88fb$at2l$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Fri, 02 Jan 2026 16:49:30 +0000 (UTC) Injection-Info: dont-email.me; posting-host="1835d86fa916216d0804243b2e2c589b"; logging-data="491172"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ujvSgeiAg0iR4iG7HVGzIx8BYTTaiaxg=" Cancel-Lock: sha1:cy74+lLq+GABpwxnkhrM5LP4qOI= X-Newsreader: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Xref: csiph.com comp.os.linux.misc:80324 alt.folklore.computers:233051 On Fri, 2 Jan 2026 10:59:55 +0000 The Natural Philosopher wrote: > > If you really needed 100 variant record in Turbo Pascal, > > then you needed 100 unions in C. > > No. You simply used *casting* . > > k=*(int *)(buffer +4) etc etc. You do have to be careful with this as it's not guaranteed that the compiler won't take liberties in arranging members of a struct for optimization purposes, and any means to ensure that it doesn't are implementation-specific, so assumptions about casting a block of memory to one struct/array or another can lead to portability issues... ...but boy, is it handy in a pinch!