Re: [PATCH] PostgreSQL fails to build with 32bit MinGW-w64 - Mailing list pgsql-hackers

From NISHIYAMA Tomoaki
Subject Re: [PATCH] PostgreSQL fails to build with 32bit MinGW-w64
Date
Msg-id 91BDAB66-3197-4478-A9DF-F7354557E435@staff.kanazawa-u.ac.jp
Whole thread Raw
In response to Re: [PATCH] PostgreSQL fails to build with 32bit MinGW-w64  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: [PATCH] PostgreSQL fails to build with 32bit MinGW-w64
List pgsql-hackers
Hi,

A new patch:
check for the presence of crtdefs.h in configure

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

Perhaps there is no guarantee that mingw (not -w64) may not have crtdefs.h in the future versions.
the 3 lines
 #define errcode __msvc_errcode
 #include <crtdefs.h>
 #undef errcode
should be valid as far as crtdefs.h exists and errcode is not defined previously.
Because this is the first system include file, we can be sure errcode is not
defined by this point.
So, I believe its better to just test for the presence of crtdefs.h rather than
try to figure out the name of compiler.

check for fseeko and ftello macro definition before defining to avoid
warning in mingw-w64 4.7.0 20110827

This patch was tested to build successfully on
mingw gcc version 4.6.1
mingw-w64 i686-w64-mingw32 gcc version 4.5.4 20110812
mingw-w64 x86_64-w64-mingw32 gcc version 4.7.0 20110827





On 2011/12/02, at 1:29, Andrew Dunstan wrote:

>
>
> On 11/27/2011 09:18 AM, NISHIYAMA Tomoaki wrote:
>> Hi,
>>
>>>>>> +/* __MINGW64_VERSION_MAJOR is related to both 32/64 bit gcc compiles by
>>>>>> + * mingw-w64, however it gots defined only after
>>>>>> Why not use __MINGW32__, which is defined without including any headers?
>>>> Because it's defined by other than mingw-w64 compilers.
>>> I see. That's because mingw (not -w64).
>>> Should it be ok if mingw is ok with that condition?
>>
>> This really breaks mingw gcc 4.6.1 :( it does not have crtdefs.h)
>> If moving downward do not break MSVC, perhaps its the good way.
>> Otherwise, we might check for the presence of crtdefs.h with configure?
>>
>
>
> I have looked at this a bit. It's fairly ugly, and the only moderately clean way I see forward is a configure test to
checkfor a mingw-w64 compiler, e.g. by running gcc -E -dM over a file which just includes stdio.h and checking for the
definednessof __MINGW64__VERSION_MAJOR, or something similar. 
>
>
> cheers
>
> andrew
>
>
>
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>


Attachment

pgsql-hackers by date:

Previous
From: Kohei KaiGai
Date:
Subject: Re: [v9.2] Fix Leaky View Problem
Next
From: Kohei KaiGai
Date:
Subject: Re: Prep object creation hooks, and related sepgsql updates