inet_* functions on Windows
Unfortunately, these headers are "interesting" on Windows. They
absolutely have to be included prior to <windows.h> which is included
from other system headers (nu surprise there). In some earlier version
of this patch this was not a problem, but I suspect that our
config.h-ification for the `LIBYANG_API_{DEF,DECL}` made stuff more
complex :(.
TL;DR: make sure that our "compat.h" goes in first, otherwise Bad
Things™ happen.
diff --git a/compat/compat.h.in b/compat/compat.h.in
index df9449b..0f99765 100644
--- a/compat/compat.h.in
+++ b/compat/compat.h.in
@@ -15,6 +15,12 @@
#ifndef _COMPAT_H_
#define _COMPAT_H_
+#ifdef _WIN32
+/* headers are broken on Windows, which means that some of them simply *have* to come first */
+# include <winsock2.h>
+# include <ws2tcpip.h>
+#endif
+
#include <limits.h>
#include <pthread.h>
#include <stdarg.h>
diff --git a/compat/posix-shims/unistd.h b/compat/posix-shims/unistd.h
index 85040b2..95bcecc 100644
--- a/compat/posix-shims/unistd.h
+++ b/compat/posix-shims/unistd.h
@@ -1,6 +1,10 @@
#ifndef _UNISTD_H
#define _UNISTD_H 1
+/* headers are broken on Windows, which means that some of them simply *have* to come first */
+# include <winsock2.h>
+# include <ws2tcpip.h>
+
/* This is intended as a drop-in replacement for unistd.h on Windows.
* Please add functionality as neeeded.
* https://stackoverflow.com/a/826027/1202830