Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!caip!nike!cad!pavepaws!keppel From: keppel@pavepaws.berkeley.edu (David Keppel) Newsgroups: net.lang.c Subject: Re: typedef scope mess Message-ID: <548@cad.BERKELEY.EDU> Date: Tue, 10-Jun-86 00:02:29 EDT Article-I.D.: cad.548 Posted: Tue Jun 10 00:02:29 1986 Date-Received: Thu, 12-Jun-86 01:30:10 EDT References: <1003@g.cs.cmu.edu> Sender: news@cad.BERKELEY.EDU Reply-To: keppel@pavepaws.UUCP (David Keppel) Organization: University of California, Berkeley Lines: 47 Keywords: K&R C typedef scope Summary: It *is* in my K&R In article <1003@g.cs.cmu.edu> ckk@g.cs.cmu.edu (Chris Koenigsberg) writes: >not in MY K&R!! > >tps@sdchem said the following program should be legal as it was from >"K&R p.206": >> typedef float distance; >> >> main() >> { >> >> auto int distance; >> >> /*###8 [cc] unknown size%%%*/ >> /*###8 [cc] cannot recover from earlier errors: goodbye!%%%*/ >> /*###8 [cc] syntax error%%%*/ >> /*###8 [cc] warning: illegal combination of pointer and integer, op =%%%*/ >> distance = 1; >> printf( "distance = %d\n", distance ); >> } Well here's what's in my K&R (1978) pg 206: KR KR Remember also (section 8.5) that identifiers associated with KR ordinary variables on the one hand and those associated with KR structure and union members and tags on the other form two disjoint KR classes which do not conflict. Members and tags follow the same KR scope rules as other identifiers. typedef [sic] names are in the KR same class as ordinary identifiers. They may be redeclared in inner KR blocks, but an explicit type must be given in the inner declaration: KR KR typedef float distance; KR ... KR { KR auto int distance; KR ... KR KR The int must be present in the second declaration, or it would be KR taken to be a declaration with no declarators and type KR distance[dagger]. KR KR ------- KR [dagger] It is agreed that the ice is thin here. :-D avid K eppel ..!ucbvax!pavepaws!keppel "Learning by Osmosis: Gospel in, Gospel out"