This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Include ws2tcpip.h to get IPv6 definitions
authorJan Dubois <jand@activestate.com>
Thu, 25 Nov 2010 20:23:05 +0000 (12:23 -0800)
committerJan Dubois <jand@activestate.com>
Thu, 25 Nov 2010 22:23:05 +0000 (14:23 -0800)
This commit also moves down the 'extern "C"' wrapper so that
it doesn't apply to any #included headers because they may
generate C++ code (templates) which doesn't confirm to "C"
linkage (when this header is included in C++ mode, e.g. while
compiling win32/perllib.c).

win32/include/sys/socket.h

index 03b60e2..d551d4b 100644 (file)
@@ -6,29 +6,37 @@
 #ifndef  _INC_SYS_SOCKET
 #define  _INC_SYS_SOCKET
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #define WIN32_LEAN_AND_MEAN
 #ifdef __GNUC__
 #  define Win32_Winsock
 #endif
 #include <windows.h>
 
-
 /* Too late to include winsock2.h if winsock.h has already been loaded */
 #ifndef _WINSOCKAPI_
 #  if defined(UNDER_CE) && UNDER_CE <= 300
      /* winsock2 only for 4.00+ */
 #    include <winsock.h>
 #  else
-#  include <winsock2.h>
-#endif
+#    include <winsock2.h>
+     /* We need to include ws2tcpip.h to get the IPv6 definitions.
+      * It will in turn include wspiapi.h.  Later versions of that
+      * header in the Windows SDK generate C++ template code that
+      * can't be compiled with VC6 anymore.  The _WSPIAPI_COUNTOF
+      * definition below prevents wspiapi.h from generating this
+      * incompatible code.
+      */
+#    define _WSPIAPI_COUNTOF(_Array) (sizeof(_Array) / sizeof(_Array[0]))
+#    include <ws2tcpip.h>
+#  endif
 #endif
 
 #include "win32.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef ENOTSOCK
 #define ENOTSOCK       WSAENOTSOCK
 #endif