From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: Stephen Frost <sfrost@snowman.net>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix for globals.c- c.h must come first
Date: Tue, 19 Jun 2018 11:15:26 -0700
Message-ID: <20180619181526.sherq6nnxdtvjvhl@alap3.anarazel.de> (raw)
In-Reply-To: <1904.1529431755@sss.pgh.pa.us>
References: <E1fJqYB-0006yo-La@gemulon.postgresql.org>
<20180619175834.GE3637@momjian.us>
<1904.1529431755@sss.pgh.pa.us>
On 2018-06-19 14:09:15 -0400, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > On Sat, May 19, 2018 at 01:20:47AM +0000, Stephen Frost wrote:
> >> Commit da9b580 mistakenly put a system header before postgres.h (which
> >> includes c.h). That can cause portability issues and broke (at least)
> >> builds with older Windows compilers.
>
> > I assume there is no way to add defined and checks to globals.c and c.h
> > to cause a compile error when this happens.
>
> Hm. You could imagine adding something like
>
> #ifdef some-relevant-macro
> #error include ordering problem, c.h must come before system headers
> #endif
>
> near the head of c.h. But I'm not sure how we'd get full coverage.
> The case presumably would only occur for off-the-beaten-path headers
> (this particular mistake was <sys/stat.h>), and there are lots of those.
If we were ok with doing this in a very platform specific manner, we
probably could make the dependency fairly generic. I.e. glibc IIRC will
pretty much always end up including features.h, so we could check for
that (#ifdef _FEATURES_H). I'd suspect other C libraries have similar
things.
Greetings,
Andres Freund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: andres@anarazel.de, tgl@sss.pgh.pa.us, bruce@momjian.us, sfrost@snowman.net
Subject: Re: pgsql: Fix for globals.c- c.h must come first
In-Reply-To: <20180619181526.sherq6nnxdtvjvhl@alap3.anarazel.de>
References: <E1fJqYB-0006yo-La@gemulon.postgresql.org> <20180619175834.GE3637@momjian.us> <1904.1529431755@sss.pgh.pa.us> <20180619181526.sherq6nnxdtvjvhl@alap3.anarazel.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox