Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!brl-tgr!tgr!gwyn@BRL-VLD.ARPA From: Doug Gwyn (VLD/VMB)Newsgroups: net.lang.c Subject: Re: type punning Message-ID: <8132@brl-tgr.ARPA> Date: Fri, 8-Feb-85 09:35:50 EST Article-I.D.: brl-tgr.8132 Posted: Fri Feb 8 09:35:50 1985 Date-Received: Sun, 10-Feb-85 04:11:21 EST Sender: news@brl-tgr.ARPA Organization: Ballistic Research Lab Lines: 17 Sigh. One can usually get away with punning different (struct XXX *)s because in a given implementation struct pointers probably all have a uniform representation. On the other hand, head->id[3] where the member id[] has only been declared of length 3 is illegal BECAUSE such usage may not work in general (for adjacent char arrays it usually does, but there is no guarantee of this in the language specification). If you happen to KNOW that you have e.g. a VAX, then of course you can cheat on the rules and get away with it. However, the same code may break miserably if run on some other machine (say, an S-1). To say that a MACHINE is non-portable just because its architecture is not that of a VAX strikes me as pretty silly. Lots of us have a variety of machines to cope with, and these VAX-specific tricks just get in the way. By the way, there are other ways to code linked lists while following the language rules. The example you gave is woefully short on error detection if a coding error is made and the wrong sort of structure is linked into a list.