Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!think!nike!cad!ucbvax!hplabs!sdcrdcf!trwrb!jsisi From: jsisi@trwrb.UUCP (Dan Jones) Newsgroups: net.lang.c Subject: Re: typedef scope mess Message-ID: <1124@trwrb.UUCP> Date: Wed, 11-Jun-86 09:00:32 EDT Article-I.D.: trwrb.1124 Posted: Wed Jun 11 09:00:32 1986 Date-Received: Sat, 14-Jun-86 06:38:40 EDT References: <1003@g.cs.cmu.edu> Reply-To: jsisi@trwrb.UUCP (Dan Jones) Organization: TRW EDS, Redondo Beach, CA Lines: 31 Summary: Try Green Hills, In K&R but flagged In article <1003@g.cs.cmu.edu> ckk@g.cs.cmu.edu (Chris Koenigsberg) writes: >Keywords:not in MY K&R!! This is in reference to the note by tps@sdchem about the code fragment found on page 206 of K & R. It is there in App. A of my volume (ISBN 0-13-110163-3, 1978), *BUT* it is flagged with a footnote which reads: "It is agreed that the ice is thin here." The footnote refers to the requirement of "auto int distance" rather than "auto distance" to avoid confusing the declaration syntax, but it is clear than the same scoping issue must have been in the back of someone's mind. And now for something completely different ... I tried the code here using the Green Hills C compiler and it handled the scoping issue 'correctly'. The pcc based UniSoft compiler muffed it exactly as reported by tps@sdchem. Thus, I would suggest being very careful since you never know what compiler your code may see next. Not only that, but it is just plain bad design to overload typedefs, depending on scoping to save the functionality of the code. [Couldn't resist my two cents worth.] Dan Jones ...!trwrb!jcc-one!djones Here is the code fragment for those who may have missed it: typedef float distance; main() { auto int distance; distance = 1; printf( "distance = %d\n", distance ); }