Re: Further simplification of c.h's #include section - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Further simplification of c.h's #include section
Date
Msg-id 7561.1510784531@sss.pgh.pa.us
Whole thread Raw
In response to Re: Further simplification of c.h's #include section  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Further simplification of c.h's #include section  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
I wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
>> On Wed, Nov 15, 2017 at 4:32 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> How do you feel about "win32_more.h"?

>> Seems morally equivalent to what you had before.  I think what I would
>> be looking for is a filename that somehow conveys what the difference
>> is between what should go in the existing file and what should go in
>> the new file.  If we don't know, maybe we should find out before we
>> change things.

> Well, the point is whether it gets included before or after the key
> system header files.  "win32_post_headers.h", perhaps?

Actually, on closer inspection, it seems like there's no need for
a windows-specific #include right there at all.  We could move
almost everything that's currently in win32.h to be done in port.h,
at the bottom of c.h rather than at the top.  The only exception
is stuff that would affect #if decisions taken in c.h itself, which
it looks like is only PGDLLIMPORT/PGDLLEXPORT, and those two could
perfectly well be declared before importing system headers.

Now, dropping everything in win32.h into port.h is surely no improvement,
but it seems like we could move all that stuff to a new file
"win32_port.h" and have the bottom of c.h look like

/* Windows-specific compatibility functions */
#if defined(WIN32) || defined(__CYGWIN__)
#include "win32_port.h"
#endif

/* Generic compatibility functions */
#include "port.h"

or else make the new file a sub-include of port.h.

There's also some fair-size stanzas in port.h that could arguably
be moved into win32_port.h if we did it like this.  I think the
parts that are #if WIN32 something #else something-else #endif
are fine as-is, but the parts that are just WIN32 without any
corresponding non-Windows code could be moved.

Thoughts?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Dmitry Dolgov
Date:
Subject: Re: [HACKERS] [PATCH] Generic type subscripting
Next
From: Michael Paquier
Date:
Subject: Re: [HACKERS] Timeline ID in backup_label file