Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: rbowman Newsgroups: comp.os.linux.misc,alt.folklore.computers Subject: Re: C structure portability, naughty Python Date: 3 Jan 2026 00:08:34 GMT Lines: 11 Message-ID: References: <20260102084925.000040b5@gmail.com> <10j92kb$v2e$1@gal.iecc.com> <10j9a1l$1toj$1@gal.iecc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net FI7Xg+qpuAs0HA/Q70m10A3kr1c2nOcViX2McuZUMb+zLK9P+W Cancel-Lock: sha1:ZHnhYgzlXtYuOnG7VqO7l1TEhlA= sha256:BOBlYCqzQXF7yD6wx/8E/JnXEzRrj+ugj/TNNmDGS5o= User-Agent: Pan/0.162 (Pokrosvk) Xref: csiph.com comp.os.linux.misc:80367 alt.folklore.computers:233093 On Fri, 2 Jan 2026 20:32:53 -0000 (UTC), John Levine wrote: > C doesn't have variant records, but you can fake them with structures > with common initial fields. The different structures can be different > sizes so the usual approach is to malloc() them one at a time and use a > pointer to it. Another approach is to have a struct containing union of structs with a flag in the top level struct indicating which child struct to use in the union. The structs in the union can also have unions so you can build a real octopus.