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 01:40:18 |
Message-ID: | 1792517.1677721218@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I wrote:
> Peter Smith <smithpb2250(at)gmail(dot)com> writes:
>> On Thu, Mar 2, 2023 at 10:04 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Sadly, this is almost certainly going to cause bitching on the part of
>>> some compilers, because depending on the order of header inclusions
>>> they are going to see multiple typedefs for the same name.
>> So does your reply mean there is no way really to be sure if such
>> changes are OK or not, other than to push them and then revert them
>> if/when one of the BF animals complains?
> We know which compilers don't like that, I believe, but you'd have
> to dig in the commit log or mail archives to find out.
I looked into the C standard to see what I could find about this.
C99 specifically describes the use of "struct foo" to forward-declare
a struct type whose meaning will be provided later. It also says
[#8] If a type specifier of the form
struct-or-union identifier
or
enum identifier
occurs other than as part of one of the above forms, and a
declaration of the identifier as a tag is visible, then it
specifies the same type as that other declaration, and does
not redeclare the tag.
which appears to me to specifically authorize the appearance of
multiple forward declarations. On the other hand, no such wording
appears for typedefs; they're just plain identifiers with the same
scope rules as other identifiers. Maybe later versions of the C
spec clarify this, but I think duplicate typedefs are pretty
clearly not OK per C99. Perhaps with sufficiently tight warning
or language-version options, you could get modern gcc or clang to
complain about it.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Melanie Plageman | 2023-03-02 01:41:14 | Re: Should vacuum process config file reload more often |
Previous Message | Michael Paquier | 2023-03-02 01:26:39 | Re: Commitfest 2023-03 starting tomorrow! |