diff --git a/src/include/port/win32.h b/src/include/port/win32.h
index e3aade316fd9ea945d2d5c64d5000d864e80ed99..22a266d0458c79f36d62be9492be9138903f132b 100644
--- a/src/include/port/win32.h
+++ b/src/include/port/win32.h
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.81 2007/11/24 01:55:26 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.82 2007/12/11 14:34:43 mha Exp $ */
 
 #if defined(_MSC_VER) || defined(__BORLANDC__)
 #define WIN32_ONLY_COMPILER
@@ -45,6 +45,17 @@
 
 #define USES_WINSOCK
 
+/*
+ * Ensure that anyone building an extension is using a 32 bit time_t.
+ * On Mingw/Msys, that should always be the case, but MSVC++ defaults
+ * to 64 bits. We set that for our own build in the project files
+ */
+#ifdef WIN32_ONLY_COMPILER
+#ifndef _USE_32BIT_TIME_T
+#error "Postgres uses 32 bit time_t - add #define _USE_32BIT_TIME_T on Windows"
+#endif
+#endif
+
 /* defines for dynamic linking on Win32 platform */
 #if defined(WIN32) || defined(__CYGWIN__)
 
diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 23749844e6d5bc585a986bfc41dc1e6a38fb35dc..b11bf75e80821a2b973989a3b41991971c641df6 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -3,7 +3,7 @@ package Project;
 #
 # Package that encapsulates a Visual C++ project file generation
 #
-# $PostgreSQL: pgsql/src/tools/msvc/Project.pm,v 1.14 2007/08/21 15:10:41 mha Exp $
+# $PostgreSQL: pgsql/src/tools/msvc/Project.pm,v 1.15 2007/12/11 14:34:43 mha Exp $
 #
 use Carp;
 use strict;
@@ -489,7 +489,7 @@ sub WriteConfiguration
 	ConfigurationType="$cfgtype" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2" WholeProgramOptimization="$p->{wholeopt}">
 	<Tool Name="VCCLCompilerTool" Optimization="$p->{opt}"
 		AdditionalIncludeDirectories="$self->{prefixincludes}src/include;src/include/port/win32;src/include/port/win32_msvc;$self->{includes}"
-		PreprocessorDefinitions="WIN32;_WINDOWS;__WINDOWS__;__WIN32__;EXEC_BACKEND;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE$self->{defines}$p->{defs}"
+		PreprocessorDefinitions="WIN32;_WINDOWS;__WINDOWS__;__WIN32__;EXEC_BACKEND;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T$self->{defines}$p->{defs}"
 		StringPooling="$p->{strpool}"
 		RuntimeLibrary="$p->{runtime}" DisableSpecificWarnings="$self->{disablewarnings}"
 EOF