Xref: utzoo comp.lang.c:20941 comp.std.c:1545
Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!rutgers!dptg!att!cbnewsl!dfp
From: dfp@cbnewsl.ATT.COM (david.f.prosser)
Newsgroups: comp.lang.c,comp.std.c
Subject: Re: type-redef's (was: va_list used in )
Message-ID: <1544@cbnewsl.ATT.COM>
Date: 19 Aug 89 16:40:47 GMT
References: <3020@solo1.cs.vu.nl>
Reply-To: dfp@cbnewsl.ATT.COM (david.f.prosser)
Organization: AT&T Bell Laboratories
Lines: 44

In article <3020@solo1.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes:
>The pANS allows a preprocessor redefinition equal to the original definition:
>
>	#define		pipo		aap
>	#define		pipo		aap
>	#define		clown(x, y)	monkey(y, x)
>	#define		clown(a, b)	monkey(b, a)	/* allowed? */

The parameter names must match as well, thus this example is not a
valid (benign) redefinition, even though they are functionally equivalent.

>
>Why is a type-redef still forbidden?
>
>	typedef		foo	bar;
>	typedef		foo	bar;

Macro definitions are easy to distinguish from regular text.  Testing
for valid redefinition is (mostly) a simple text-based comparison.
Typedef names are more difficult to manage.  For example, given

	typedef int INT;
then
	{ typedef unsigned INT;

is a declaration of a local typedef name representing "unsigned int".
But if the first typedef was followed by

	{ typedef const INT;

then it is a "useless" declaration because const and volatile are
allowed to modify a known typedef name.  (Such a "useless" declaration
is required to cause a diagnostic.)

Many C compilers choose to recognize typedef names as special in the
lexical analysis stage, primarily because the grammar makes a big
distinction between regular and typedef names.  Allowing benign
redefinition of typedef names makes this tricky process even more
complex.

Nevertheless, I believe that they should have been allowed, but that's
only my opinion.

Dave Prosser	...not an official X3J11 answer...