When building with Kerberos support (or GSSAPI, but not SSPI) on Win32, a
whole bunch of warnings come out due to redefinitions of macros in the
kerberos headers. The reason for this is that Kerberos leaks the
HAVE_<something> macros from autoconf into the header files that are
included by PostgreSQL. 

The attached file removes this by undefing the macros before we include the
kerberos files. But this is perhaps just too ugly to deal with and we
should live with the warnings instead?

For MSVC, we can suppress the warnings with a #pragma around the include,
but I don't know if that's possible in mingw/gcc. It'll look something likt
the second patch attached (only did that for one of the places that'd need
it, to show what it looks like)

Thoughts? Worth doing anything about?

//Magnus
Index: src/backend/libpq/auth.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/libpq/auth.c,v
retrieving revision 1.155
diff -c -r1.155 auth.c
*** src/backend/libpq/auth.c    24 Jul 2007 09:00:27 -0000      1.155
--- src/backend/libpq/auth.c    24 Jul 2007 10:21:26 -0000
***************
*** 96,101 ****
--- 96,113 ----
   *----------------------------------------------------------------
   */

+ #ifdef WIN32
+ /*
+  * Kerberos on windows leaks header definitions from autoconf, causing a
+  * bunch of warnings. Undefine those here and let krb redefine them.
+  */
+ #undef HAVE_NETINET_IN_H
+ #undef HAVE_STRING_H
+ #undef HAVE_STRDUP
+ #undef HAVE_STRERROR
+ #undef HAVE_SYS_TYPES_H
+ #undef HAVE_STDLIB_H
+ #endif
  #include <krb5.h>
  /* Some old versions of Kerberos do not include <com_err.h> in <krb5.h> */
  #if !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)
Index: src/include/libpq/libpq-be.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/libpq/libpq-be.h,v
retrieving revision 1.62
diff -c -r1.62 libpq-be.h
*** src/include/libpq/libpq-be.h        23 Jul 2007 10:16:54 -0000      1.62
--- src/include/libpq/libpq-be.h        24 Jul 2007 10:16:25 -0000
***************
*** 30,35 ****
--- 30,47 ----
  #endif

  #ifdef ENABLE_GSS
+ #ifdef WIN32
+ /*
+  * Kerberos on windows leaks header definitions from autoconf, causing a
+  * bunch of warnings. Undefine those here and let krb redefine them.
+  */
+ #undef HAVE_NETINET_IN_H
+ #undef HAVE_STRING_H
+ #undef HAVE_STRDUP
+ #undef HAVE_STRERROR
+ #undef HAVE_SYS_TYPES_H
+ #undef HAVE_STDLIB_H
+ #endif
  #if defined(HAVE_GSSAPI_H)
  #include <gssapi.h>
  #else
Index: src/interfaces/libpq/fe-auth.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v
retrieving revision 1.131
diff -c -r1.131 fe-auth.c
*** src/interfaces/libpq/fe-auth.c      24 Jul 2007 09:00:27 -0000      1.131
--- src/interfaces/libpq/fe-auth.c      24 Jul 2007 10:21:03 -0000
***************
*** 54,59 ****
--- 54,71 ----
   * MIT Kerberos authentication system - protocol version 5
   */

+ #ifdef WIN32
+ /*
+  * Kerberos on windows leaks header definitions from autoconf, causing a
+  * bunch of warnings. Undefine those here and let krb redefine them.
+  */
+ #undef HAVE_NETINET_IN_H
+ #undef HAVE_STRING_H
+ #undef HAVE_STRDUP
+ #undef HAVE_STRERROR
+ #undef HAVE_SYS_TYPES_H
+ #undef HAVE_STDLIB_H
+ #endif
  #include <krb5.h>
  /* Some old versions of Kerberos do not include <com_err.h> in <krb5.h> */
  #if !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)
Index: src/interfaces/libpq/libpq-int.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/libpq-int.h,v
retrieving revision 1.126
diff -c -r1.126 libpq-int.h
*** src/interfaces/libpq/libpq-int.h    23 Jul 2007 18:59:50 -0000      1.126
--- src/interfaces/libpq/libpq-int.h    24 Jul 2007 10:14:28 -0000
***************
*** 45,50 ****
--- 45,62 ----
  #include "pqexpbuffer.h"

  #ifdef ENABLE_GSS
+ #ifdef WIN32
+ /*
+  * Kerberos on windows leaks header definitions from autoconf, causing a
+  * bunch of warnings. Undefine those here and let krb redefine them.
+  */
+ #undef HAVE_NETINET_IN_H
+ #undef HAVE_STRING_H
+ #undef HAVE_STRDUP
+ #undef HAVE_STRERROR
+ #undef HAVE_SYS_TYPES_H
+ #undef HAVE_STDLIB_H
+ #endif
  #if defined(HAVE_GSSAPI_H)
  #include <gssapi.h>
  #else
Index: src/interfaces/libpq/libpq-int.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/libpq-int.h,v
retrieving revision 1.126
diff -c -r1.126 libpq-int.h
*** src/interfaces/libpq/libpq-int.h    23 Jul 2007 18:59:50 -0000      1.126
--- src/interfaces/libpq/libpq-int.h    24 Jul 2007 10:29:02 -0000
***************
*** 45,55 ****
--- 45,61 ----
  #include "pqexpbuffer.h"
  
  #ifdef ENABLE_GSS
+ #ifdef WIN32_ONLY_COMPILER
+ #pragma warning(disable:4005)
+ #endif
  #if defined(HAVE_GSSAPI_H)
  #include <gssapi.h>
  #else
  #include <gssapi/gssapi.h>
  #endif
+ #ifdef WIN32_ONLY_COMPILER
+ #pragma warning(default:4005)
+ #endif
  #endif
  
  #ifdef ENABLE_SSPI
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to