Re: Issues with MinGW W64 - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Issues with MinGW W64
Date
Msg-id 15750.1338315592@sss.pgh.pa.us
Whole thread Raw
In response to Re: Issues with MinGW W64  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Issues with MinGW W64
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Tue, May 29, 2012 at 9:04 AM, Johann 'Myrkraverk' Oskarsson
> <johann@2ndquadrant.com> wrote:
>> The header file crtdefs.h in MinGW typedefs errcode which conflicts with
>> Postgres' elog.h.

> Eep.  Maybe this is not directly relevant, but I guess my first
> question is: why is MinGW doing that?

I concur with Robert here: your first step should be to push back on the
MinGW developers about this nonstandard intrusion on application
namespace.  We've been using errcode() as a function name since 2003,
and it's never been a problem before on any platform, including previous
versions of MinGW.

If they won't change it, then we could consider some other hack, but
that should really be the first attempt.

>> MinGW W64's sys/stat.h #defines stat to be _stati64 and there is
>> subsequently a compilation error in port.h:
>> 
>> note: expected 'struct _stati64 *' but argument is of type 'struct stat *'
>> error: conflicting types for 'pgwin32_safestat'

> In this case, I really think we ought to change all backend calls that
> hit stat() to use something like pgstat() instead.

I disagree with this conclusion.  That'd be an unnecessarily nonstandard
notation, which all existing and future developers would have to learn.
I'd rather work around this in port.h if at all possible.  I'm not quite
sure why the existing code fails, though --- is there a conflict between
"#define stat" and "#define stat(a,b)"?

>> There are series of redefined macros from the MinGW W64 CRT.
>> ...
>> And possibly some more.  Do we need these redefines?

> We probably need them somewhere, or they wouldn't have been added.
> But maybe we don't need them on the exact platform you're using.

Can we deal with this by just wrapping each #define in #ifndef?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: pg_upgrade libraries check
Next
From: Tom Lane
Date:
Subject: Re: pg_upgrade libraries check