Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.UUCP Newsgroups: comp.lang.c Subject: Re: Unions that generate offsets (?) Message-ID: <6424@brl-smoke.ARPA> Date: Sat, 12-Sep-87 17:07:59 EDT Article-I.D.: brl-smok.6424 Posted: Sat Sep 12 17:07:59 1987 Date-Received: Sun, 13-Sep-87 08:49:43 EDT References: <167@jc3b21.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 24 Keywords: union structure offset In article <167@jc3b21.UUCP> crash@jc3b21.UUCP (Frank (Crash) Edwards) writes: >Given the following definition, should the reference "msg.m_union.m_from" >be a legal reference to the member of the "pckt" structure? No. You forgot to include ".pckt" in the reference. >And should >it reference the first location of m_union or the first location of pckt? Assuming you fix that, it references the "m_from" member, naturally. > "Such constructions are non-portable." Yup, they were allowed by a particular implementation of C, not by the language rules. >First of all, this paragraph should read, "but if preceding member *types* >differ". No, K&R had it right. If preceding members (member names) differ, the result is non-portable. Some compilers won't even allow it. Why don't you just do this the right way (fully-qualified member path), rather than try to cheat?