Why are typedef names in the same name space as variable names?
Doug Gwyn
gwyn at brl-smoke.ARPA
Sun Dec 7 02:51:10 AEST 1986
In article <6430 at alice.uUCp> bs at alice.UUCP writes:
>file1:
> typedef int I;
> I i = 1;
>file2:
> typedef char* I;
> I p = "asdf";
>Is it legal? Personally, I think not because the name I which is external by
>default has two definitions (but the C++ compiler also accepts it).
I see no more reason to consider the abbreviation `I' external than
to do so for `COUNTER' in the following scenario:
file1:
#define COUNTER int
COUNTER i = 1;
file2:
#define COUNTER long
COUNTER l = 0;
It appears to depend on whether one considers typedef to be a convenient
shorthand or something more fundamental. If you adopt your view, then
one needs to allow declarations such as:
static typedef int I;
More information about the Comp.lang.c
mailing list