Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!gatech!emory!platt
From: platt@emory.uucp (Dan Platt)
Newsgroups: comp.sys.ibm.pc
Subject: Re: Problems with MSC 5.0
Message-ID: <2355@emory.uucp>
Date: Sat, 28-Nov-87 13:46:18 EST
Article-I.D.: emory.2355
Posted: Sat Nov 28 13:46:18 1987
Date-Received: Mon, 30-Nov-87 04:08:02 EST
References: <754@pilchuck.Data-IO.COM> <1610047@hpcvlo.HP.COM> <1203@lznv.ATT.COM>
Reply-To: platt@emory.UUCP (Dan Platt)
Organization: Emory University
Lines: 47

In article <1203@lznv.ATT.COM> psc@lznv.ATT.COM (Paul S. R. Chisholm) writes:
>
>
>In article <1610047@hpcvlo.HP.COM>, jason@hpcvlo.HP.COM (Jason Su) writes:
>> /* Here's another irritating bug that compiled(!) w/o errors on MSC 4.0. */
>> typedef int map;
>> 
>> typedef struct {
>> 	int *map;		/* <-- This is the error line */	
>> } my_struct;		
>
>K&R, p. 200:  "Declarations whose 'storage class' is typedef do not
>define storage, but instead DEFINE IDENTIFIERS WHICH CAN BE USED LATER
>AS IF THEY WERE TYPE KEYWORDS . . ."  [emphasis mine]
>
>The identifier "map" is effectively a reserved keyword from the time
>its typedef is complete through the end of the compiled module.  MSC
>4.0 was incorrect in accepting this code in the first place.  I suspect
>that most C compilers that support typedef will reject it.

Actually, in this case, if the error is in the line indicated by the
comment, then there is a problem with the compiler.  The reserved word
is 'my_struct', not 'map'.  As an example, I've constructed the following
toy program:


#include 

typedef struct { int *map;} my_stor;
my_stor map;

main()
{
	printf("I guess there was no complaint.\n");
	map.map = (int *)malloc(sizeof(int));
	*(map.map)=5;
	printf("%d\n",*(map.map));
}

This program runs quite well on a Sun, a Vax and on my PC (using turboC) with
no problems.  Plus, as pointed out K&R were quite explicit in defining the
variable as a type (in this case, the variable being declared was my_struct
as a structure containing a pointer to an integer called map).

Hope this clears things up...

Dan Platt