The C-preprocessor in Visual-C (even in MSVC 2015) is pretty
lame compared to Gnu-C. In select.c (around line 317 and 523):
r = select((int)maxfd + 1,
#ifndef USE_WINSOCK
&fds_read,
&fds_write,
#else
fds_read.fd_count ? &fds_read : NULL,
fds_write.fd_count ? &fds_write : NULL,
#endif
&fds_err, ptimeout);
this causes lots of parse errors since with USE_LWIPSOCK, select() is a
macro (-> lwip_select()). And MSVC doesn't like a '#' inside macros.
The attached patch reverses the logic. IMHO '#ifdef USE_WINSOCK' is more
readable than '#ifndef USE_WINSOCK'.
--
--gv
--- a/select.c 2015-03-25 23:39:26
+++ b/select.c 2015-12-07 13:48:49
@@ -316,15 +316,18 @@
curl_socket_t is unsigned in such cases and thus -1 is the largest
value).
*/
+#ifdef USE_WINSOCK
r = select((int)maxfd + 1,
-#ifndef USE_WINSOCK
- &fds_read,
- &fds_write,
-#else
fds_read.fd_count ? &fds_read : NULL,
fds_write.fd_count ? &fds_write : NULL,
-#endif
&fds_err, ptimeout);
+#else
+ r = select((int)maxfd + 1,
+ &fds_read,
+ &fds_write,
+ &fds_err, ptimeout);
+#endif
+
if(r != -1)
break;
error = SOCKERRNO;
@@ -505,19 +508,21 @@
pending_tv.tv_sec = 0;
pending_tv.tv_usec = 0;
}
+
+#ifdef USE_WINSOCK
r = select((int)maxfd + 1,
-#ifndef USE_WINSOCK
- &fds_read, &fds_write, &fds_err,
-#else
/* WinSock select() can't handle fd_sets with zero bits set, so
don't give it such arguments. See the comment about this in
Curl_check_socket().
*/
fds_read.fd_count ? &fds_read : NULL,
fds_write.fd_count ? &fds_write : NULL,
- fds_err.fd_count ? &fds_err : NULL,
+ fds_err.fd_count ? &fds_err : NULL, ptimeout);
+#else
+ r = select((int)maxfd + 1,
+ &fds_read, &fds_write, &fds_err, ptimeout);
#endif
- ptimeout);
+
if(r != -1)
break;
error = SOCKERRNO;
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html