type-redef's (was: va_list used in <stdio.h>)
david.f.prosser
dfp at cbnewsl.ATT.COM
Sun Aug 20 02:40:47 AEST 1989
In article <3020 at solo1.cs.vu.nl> maart at 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...
More information about the Comp.std.c
mailing list