Andrew Dunstan <andrew(at)dunslane(dot)net>,
NISHIYAMA Tomoaki <tomoakin(at)staff(dot)kanazawa-u(dot)ac(dot)jp>,
Magnus Hagander <magnus(at)hagander(dot)net>
Subject:
Re: [PATCH] PostgreSQL fails to build with 32bit MinGW-w64
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.