From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Peter Smith <smithpb2250(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: typedef struct LogicalDecodingContext |
Date: | 2023-03-02 02:16:45 |
Message-ID: | 1805673.1677723405@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Smith | 2023-03-02 02:17:18 | Re: typedef struct LogicalDecodingContext |
Previous Message | Masahiko Sawada | 2023-03-02 02:08:00 | Re: Time delayed LR (WAS Re: logical replication restrictions) |