Undefine setlocale() macro on Win32
authorMagnus Hagander <[email protected]>
Tue, 1 Feb 2011 12:19:18 +0000 (13:19 +0100)
committerMagnus Hagander <[email protected]>
Tue, 1 Feb 2011 12:28:06 +0000 (13:28 +0100)
New versions of libintl redefine setlocale() to a macro
which causes problems when the backend and libintl are
linked against different versions of the runtime, which
is often the case in msvc builds.

Hiroshi Inoue, slightly updated comment by me

src/include/port.h

index 094d58a442a99997855201cbe0196c1452d01e1e..fc17d56482f859b5d15280a0dd43c41db7ae02b3 100644 (file)
@@ -164,6 +164,15 @@ extern unsigned char pg_tolower(unsigned char ch);
 #ifdef printf
 #undef printf
 #endif
+/*
+ * Versions of libintl >= 0.18? try to replace setlocale() with a macro
+ * to their own versions.  Remove the macro, if it exists, because it
+ * ends up calling the wrong version when the backend and libintl use
+ * different versions of msvcrt.
+ */
+#if defined(setlocale) && defined(WIN32)
+#undef setlocale
+#endif
 
 extern int     pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
 extern int