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

From Tom Lane
Subject Further simplification of c.h's #include section
Date
Msg-id 29650.1510761080@sss.pgh.pa.us
Whole thread Raw
Responses Re: Further simplification of c.h's #include section  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Yesterday's commit 91aec93e6 got rid of quite a bit of unprincipled cruft
that had accumulated in c.h's #include section.  It occurs to me that we
could clean it up some more, eliminating almost all the Windows-specific
hacking there, by doing this:

1. Move what's currently in src/include/port/win32.h (a/k/a
pg_config_os.h) to a new file, say src/include/port/win32_2.h.

2. Move these bits of c.h into win32.h:

#if defined(_WIN32) && !defined(WIN32)
#define WIN32
#endif

#if _MSC_VER >= 1400 || defined(HAVE_CRTDEFS_H)
#define errcode __msvc_errcode
#include <crtdefs.h>
#undef errcode
#endif

3. Then the #include for pg_config_os.h just becomes unconditional and
uncluttered.

4. Below the system #includes, where we have

#if defined(WIN32) || defined(__CYGWIN__)
/* We have to redefine some system functions after they are included above. */
#include "pg_config_os.h"
#endif

I'd propose just changing that to include "port/win32_2.h".

Aside from being cleaner, this would provide a clear framework for other
platforms to inject code both before and after the system headers.
To make that happen, we'd have to set up pg_config_os_2.h symlinks and
replace the above-quoted bit with #include "pg_config_os_2.h".  I don't
feel a need to make that happen right now, but it'd be straightforward
to do it if we need to.

Once that's done, there might be reason to rethink the division of
code between win32.h and win32_2.h, but not being a Windows hacker
I'm not qualified to do that.

Thoughts, objections?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] moving some partitioning code to executor
Next
From: Robert Haas
Date:
Subject: Re: Separate leader buffer info and worker wait info in EXPLAIN output?