I wrote:
> Maybe later versions of the C
> spec clarify this, but I think duplicate typedefs are pretty
> clearly not OK per C99.

Further research shows that C11 allows this, but it's definitely
not okay in C99, which is still our reference standard.

> Perhaps with sufficiently tight warning
> or language-version options, you could get modern gcc or clang to
> complain about it.

clang seems to do so as soon as you restrict it to C99:

$ cat dup.c
typedef int foo;
typedef int foo;
$ clang -c -std=gnu99 dup.c
dup.c:2:13: warning: redefinition of typedef 'foo' is a C11 feature 
[-Wtypedef-redefinition]
typedef int foo;
            ^
dup.c:1:13: note: previous definition is here
typedef int foo;
            ^
1 warning generated.

I couldn't get gcc to issue a similar warning without resorting
to -Wpedantic, which of course whines about a ton of other stuff.

I'm a little inclined to see if I can turn on -std=gnu99 on my
clang-based buildfarm animals.  I use that with gcc for my
normal development activities, but now that I see that clang
catches some things gcc doesn't ...

                        regards, tom lane


Reply via email to