Hi all

Related to the earlier comments about building extensions on Windows, I
just noticed that we don't treat "WINDLL" as equivalent to "WIN32", and
"WIN32" isn't set in a Visual Studio DLL project.

We should actually be testing _WIN32, which is the compiler's
pre-defined macro. The attached patch to c.h takes care of that - it
tests _WIN32 in c.h and sets WIN32 early if it's found.

_WIN32 is set for both win32 and win64, like we expect from WIN32.


Without this patch, MSVC extension builds fail with:

9.3\include\server\pg_config_os.h(207): error C2011: 'timezone' :
'struct' type redefinition
1>          c:\program
files\postgresql\9.3\include\server\pg_config_os.h(207) : see
declaration of 'timezone'
1>c:\program files\postgresql\9.3\include\server\pg_config_os.h(216):
error C2011: 'itimerval' : 'struct' type redefinition
1>          c:\program
files\postgresql\9.3\include\server\pg_config_os.h(216) : see
declaration of 'itimerval'

due to double-inclusion of pg_config_os.h from c.h:57 then later on
c.h:92 . WIN32 is not defined on line 57 (so we include pg_config_os.h),
but gets defined by the include of crtdefs.h so we re-include it again
later.

This doesn't cause issues with our Perl build system because we set WIN32.

-- 
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services
diff --git a/src/include/c.h b/src/include/c.h
index 6e19c6d..61ba651 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -53,6 +53,14 @@
 #include "pg_config.h"
 #include "pg_config_manual.h"	/* must be after pg_config.h */
 
+/* 
+ * We've always relied on the WIN32 macro, but _WIN32 is the compiler
+ * pre-defined macro. So make sure we define WIN32 whenever _WIN32 is set.
+ */
+#if defined(_WIN32)
+#define WIN32
+#endif
+
 #if !defined(WIN32) && !defined(__CYGWIN__)		/* win32 includes further down */
 #include "pg_config_os.h"		/* must be before any system header files */
 #endif
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to