Re: python cleanup

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Peter Eisentraut <peter_e@gmx.net>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2011-07-25T03:46:33Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Move include for Python.h above postgres.h to eliminate compiler warning.

Andrew Dunstan <andrew@dunslane.net> writes:
> On my Linux system the attached compiles without warnings. If this seems 
> like the way to go I'll investigate more on Windows.

Hmm ...

> +/*
> + * Save settings the Python headers might override 
> + */
> +#ifdef _POSIX_C_SOURCE
> +#define _PGSAVE_POSIX_C_SOURCE _POSIX_C_SOURCE
> +#undef _POSIX_C_SOURCE
> +#endif
> ...
> +/*
> + * Restore settings the Python headers might have overridden.
> + */
> +#ifdef _PGSAVE_POSIX_C_SOURCE
> +#undef _POSIX_C_SOURCE
> +#define _POSIX_C_SOURCE _PGSAVE_POSIX_C_SOURCE
> +#undef _PGSAVE_POSIX_C_SOURCE
> +#endif

I don't believe that this sequence will restore the contents of the 
_POSIX_C_SOURCE macro to what it was before.  For that matter, it's
not even quite right about ensuring that the macro's defined-ness
status is restored (what if the python headers set _POSIX_C_SOURCE
when it wasn't set before?).  We might not need more than defined-ness
to be right, though.

What in the world are the python headers doing fooling with these
macros, anyway??

			regards, tom lane