Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!pyramid!hplabs!hao!noao!terak!anasazi!john From: john@anasazi.UUCP Newsgroups: net.unix,net.unix-wizards,net.arch,net.lang.c Subject: (Really addressing inside struct)Re: get size of malloc'd object Message-ID: <403@anasazi.UUCP> Date: Sat, 5-Jul-86 13:03:15 EDT Article-I.D.: anasazi.403 Posted: Sat Jul 5 13:03:15 1986 Date-Received: Fri, 11-Jul-86 05:57:37 EDT References: <165@daisy.UUCP> <334@valid.UUCP> <2206@peora.UUCP> Reply-To: john@anasazi.UUCP (John Moore) Organization: Anasazi, Phoenix Az. Lines: 42 Xref: watmath net.unix:8559 net.unix-wizards:18769 net.arch:3662 net.lang.c:9798 A related problem that we have found with C alignment is this: We have a structure with a number of structures contained within it. Because of linked list processing, we have a pointer to one of the structures within, and we want to derive a pointer to the top of the structure without LINT complaining, and in a truly portable way. How can this be done? Many things have been tried without success here at Anasazi. Example: struct links { struct links *forward; struct links *backward; }; struct foo { char bar; struct links snake; struct whocares junk; struct links lizard; }; struct links *reptile; Assume that reptile points to the lizard structure of a "foo" structure. What construct allows one to do the following: struct foo *iwish = (mystery function of reptile); Example of a wrong solution: struct foo *iwish = (struct foo *)((char *)reptile + (char *)0->lizard); Any help would be appreciated. -- John Moore (NJ7E) {decvax|ihnp4|hao}!noao!mot!anasazi!john {hao!noao|decvax|ihnp4|seismo}!mot!anasazi!john mot!anasazi!john@SEISMO.CSS.GOV (602) 861-7607 (day or evening) 7525 Clearwater Pkwy, Paradise Valley, AZ, 85253 (Home Address) The opinions expressed here are obviously not mine, so they must be someone else's.