diff --git a/src/include/port.h b/src/include/port.h
index 4d40cef7b4b7c5cc1bc95286b4f16399cd519363..2c58b554926ddab8b3a94d51cf50eb779824e3c2 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -176,6 +176,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