summaryrefslogtreecommitdiff
path: root/win32/include
diff options
context:
space:
mode:
authorSteve Hay <steve.m.hay@googlemail.com>2013-09-07 21:53:35 +0100
committerSteve Hay <steve.m.hay@googlemail.com>2013-09-16 15:37:36 +0100
commit4eaf3102d69324863df3d6e00970832384cdf452 (patch)
treea9b608feef6f22e15d613ab5160705e08afb2906 /win32/include
parent7b9b1b4e943aea8e8d16d497f20e2d3366df5eae (diff)
downloadperl-4eaf3102d69324863df3d6e00970832384cdf452.tar.gz
Fix the #include of winsock2.h in win32/include/sys/errno2.h
For some reason (I didn't figure out why) cpan/Win32/Win32.xs did not compile as of the previous commit, but in any case we cannot just blindly include winsock2.h because (a) it is too late if winsock.h has already been included and (b) early WinCE doesn't have it. The definition of _WINSOCKAPI_ was also wrongly not updated to _WINSOCK2API_ but was mistaken in its comment "Don't drag in everything" anyway: it's actually just an old-fashioned "include guard", not a means to include a minimal API from the file. (The mistaken comment came from the original ext/Errno/Errno_pm.PL before this round of $!-related changes. That file also had a redundant "#include <winsock.h>" left in it which should have been removed along with earlier work that removed the other one, so tidy that up too.) Steal a hopefully more correct incantation from win32/include/sys/socket.h instead. Now that we allow for the possibility of winsock.h being used again, we must take care not to make use of WSAECANCELLED if it is not defined. (That is the only WSAExxx constant which we use that was new in winsock2.h.)
Diffstat (limited to 'win32/include')
-rw-r--r--win32/include/sys/errno2.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/win32/include/sys/errno2.h b/win32/include/sys/errno2.h
index c5923ac6d5..a06fb4a423 100644
--- a/win32/include/sys/errno2.h
+++ b/win32/include/sys/errno2.h
@@ -1,8 +1,15 @@
#ifndef _INC_SYS_ERRNO2
#define _INC_SYS_ERRNO2
-#define _WINSOCKAPI_ /* Don't drag in everything */
-#include <winsock2.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
+#endif
/* Ensure all the Exxx constants required by convert_wsa_error_to_errno() in
* win32/win32sck.c are defined. Many are defined in <errno.h> already (more so
@@ -149,7 +156,9 @@
/* ENOMORE is not an errno.h value at all */
#ifndef ECANCELED /* New in VC10 */
-# define ECANCELED WSAECANCELLED
+# ifdef WSAECANCELLED /* New in WinSock2 */
+# define ECANCELED WSAECANCELLED
+# endif
#endif
/* EINVALIDPROCTABLE is not an errno.h value at all */