Re: [PATCH] PostgreSQL fails to build with 32bit MinGW-w64

NISHIYAMA Tomoaki <tomoakin@staff.kanazawa-u.ac.jp>

From: NISHIYAMA Tomoaki <tomoakin@staff.kanazawa-u.ac.jp>
To: pgsql-hackers@postgresql.org
Cc: Andrew Dunstan <andrew@dunslane.net>, NISHIYAMA Tomoaki <tomoakin@staff.kanazawa-u.ac.jp>, Magnus Hagander <magnus@hagander.net>
Date: 2011-12-05T14:31:32Z
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. Remove troublesome Asserts in cost_mergejoin().

  2. Enable building with the Mingw64 compiler.

Attachments

Hi,

If we are not to use 64 bit file size (and time),
#undef stat may be sufficient. The #undef should be
before the prototype of pgwin32_safestat because the
#define stat _stat64 affect both the function and struct stat.
The #undef stat necessitate #undef fstat as the parameter
struct stat * is changed.

Additional change are for the macro redefinition warnings.
(Suppress warnings, but perhaps not very different)

The patch is tested to compile on 
x86_64-w64-mingw32-gcc 4.7.0 20111203 (experimental)
and
gcc version 4.6.1 on MingW/MSYS

--- a/src/include/port.h
+++ b/src/include/port.h
@@ -334,6 +334,12 @@ extern bool rmtree(const char *path, bool rmtopdir);
  */
 #if defined(WIN32) && !defined(__CYGWIN__) && !defined(UNSAFE_STAT_OK)
 #include <sys/stat.h>
+#ifdef stat
+#undef stat
+#endif
+#ifdef fstat
+#undef fstat
+#endif
 extern int	pgwin32_safestat(const char *path, struct stat * buf);
 
 #define stat(a,b) pgwin32_safestat(a,b)


If this is not sufficient, we might need to change all call of stat, lstat, and fstat
to some wrapper functions?  : It's theoretically doable, but could be quite difficult
for a huge software.