Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!burl!codas!killer!academ!uhnix1!sugar!peter From: peter@sugar.UUCP Newsgroups: comp.lang.c Subject: Re: Unions that generate offsets (?) Message-ID: <720@sugar.UUCP> Date: Mon, 14-Sep-87 11:45:33 EDT Article-I.D.: sugar.720 Posted: Mon Sep 14 11:45:33 1987 Date-Received: Sat, 19-Sep-87 07:25:33 EDT References: <167@jc3b21.UUCP> Organization: Sugar Land UNIX - Houston, TX Lines: 22 Keywords: union structure offset Summary: "The compiler" is probably not your compiler. In article <167@jc3b21.UUCP>, crash@jc3b21.UUCP (Frank (Crash) Edwards) writes: > "Actually, the compiler checks only that a name in two different > structures has the same type and offset in both, but if preceding > members differ the construction is non-portable." > First of all, this paragraph should read, "but if preceding member *types* > differ". Since the compiler checks offsets, the construction is non- > portable only if the offset might change during porting. > Again the reference "the compiler" -- as if only *one* compiler existed! The book was written when basically only one compiler existed. The compiler described is the PDP-11 K&R compiler. Most modern 'C' compilers do check on the types of the structure and the member and will complain. Thus the construction is non-portable. Whenever K&R talks about "the compiler", that should cue you to regard the associated text as being suspect unless you're using a PDP-11 running version 6 or version 7 UNIX. -- -- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter -- 'U` ^^^^^^^^^^^^^^ Not seismo!soma (blush)