🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1433

Re: Order of allocation of fields in a struct?

#1433
From: Doug Gwyn
Date: Thu, 14 Jun 1990 19:02
13 lines
1048 bytes
In article <1563@diemen.cc.utas.oz> charles@tasis.eecs.utas.edu.au (Charles Lakos) writes:
>Can I then access the fields of v2 in the following way:
>  (t1 *) p -> b

No, but ((t1 *)p)->b should work.

You can count on a pointer to the first member of a struct being
convertible to a pointer to the struct and vice-versa, and from
various constraints in the standard it is possible to conclude
that "all structure pointers smell the same", meaning that they
have the same size and alignment requirements, so it is also
possible to interconvert pointers to two different structure
types.
Technical Details
Message-ID: <13115@smoke.BRL.MIL>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn
References: <1563@diemen.cc.utas.oz>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn
From: gwyn@smoke.BRL.MIL (Doug Gwyn)
Newsgroups: comp.std.c
Subject: Re: Order of allocation of fields in a struct?
Message-ID: <13115@smoke.BRL.MIL>
Date: 14 Jun 90 19:02:05 GMT
References: <1563@diemen.cc.utas.oz>
Organization: U.S. Army Ballistic Research Laboratory, APG, MD.
Lines: 13