Re: popen and pclose redefinitions causing many warning in Windows build

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: popen and pclose redefinitions causing many warning in Windows build
Date: 2014-05-08 15:19:02
Message-ID: 16856.1399562342@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> writes:
> On 05/08/2014 08:01 AM, Michael Paquier wrote:
>> Since commit a692ee5, code compilation on windows is full of warnings
>> caused by the re-definitions of popen and pclose:

> Hmm. Does the MinGW version of popen() and system() do the quoting for
> you? If we just #ifdef the defines, then we will not use the wrappers on
> MinGW, which would be wrong if the quoting is needed there. If it's not
> needed, then we shouldn't be compiling the wrapper functions in the
> first place.

Another problem, if we do need the wrappers on mingw, is that the
"#undef" commands in system.c will presumably result in the wrong
things happening in the wrapper functions, since the platform needs
us to use their macros there.

The simplest workaround I can think of is to change the stanza in
port.h to be like

#ifndef DONT_DEFINE_SYSTEM_POPEN
#undef system
#define system(a) pgwin32_system(a)
#undef popen
#define popen(a,b) pgwin32_popen(a,b)
#undef pclose
#define pclose(a) _pclose(a)
#endif

and then have system.c do #define DONT_DEFINE_SYSTEM_POPEN before
including postgres.h. This is pretty grotty, but on the other hand
it'd remove the need for the #undef's in system.c.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-05-08 15:30:13 Re: Compilation errors with mingw build caused by undefined optreset
Previous Message Robert Haas 2014-05-08 15:10:29 PQputCopyEnd doesn't adhere to its API contract