diff --git a/libretrodb/libretrodb.c b/libretrodb/libretrodb.c
index c510d634ec..91166cb393 100644
--- a/libretrodb/libretrodb.c
+++ b/libretrodb/libretrodb.c
@@ -82,9 +82,9 @@ int libretrodb_create(
         void * ctx
 ){
 	int rv;
-   off_t root;
-	uint64_t item_count = 0;
+    off_t root;
 	libretrodb_metadata_t md;
+	uint64_t item_count = 0;
 	struct rmsgpack_dom_value item = {};
 	libretrodb_header_t header = {};
 
diff --git a/libretrodb/libretrodb.h b/libretrodb/libretrodb.h
index 5998ff9df8..024b840e7a 100644
--- a/libretrodb/libretrodb.h
+++ b/libretrodb/libretrodb.h
@@ -11,6 +11,10 @@
 
 #define MAGIC_NUMBER "RARCHDB"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct libretrodb_query libretrodb_query_t;
 
 typedef struct libretrodb
@@ -126,4 +130,8 @@ int libretrodb_cursor_read_item(
         struct rmsgpack_dom_value * out
 );
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/libretrodb/rmsgpack_dom.h b/libretrodb/rmsgpack_dom.h
index c9cfdbf595..5f71f9818b 100644
--- a/libretrodb/rmsgpack_dom.h
+++ b/libretrodb/rmsgpack_dom.h
@@ -3,6 +3,10 @@
 
 #include <stdint.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum rmsgpack_dom_type {
 	RDT_NULL = 0,
 	RDT_BOOL,
@@ -64,8 +68,11 @@ int rmsgpack_dom_write(
         int fd,
         const struct rmsgpack_dom_value * obj
 );
-int rmsgpack_dom_read_into(
-        int fd,
-        ...
-);
+
+int rmsgpack_dom_read_into(int fd, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/net_http.c b/net_http.c
index 5041520d3f..470ae7e293 100644
--- a/net_http.c
+++ b/net_http.c
@@ -18,34 +18,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
-
-#if defined(_WIN32)
-	/* Much of this is copypasta from elsewhere, I don't know if it works. */
-	#define _WIN32_WINNT 0x501
-	#include <winsock2.h>
-	#include <ws2tcpip.h>
-	#define isagain(bytes) (false)
-	#define MSG_NOSIGNAL 0
-	#define close closesocket
-	#ifdef _MSC_VER
-		#pragma comment(lib, "ws2_32.lib")
-	#endif
-#else
-	//#include <sys/types.h>
-	#include <sys/socket.h>
-	#include <sys/time.h>
-	//#include <sys/un.h>
-	//#include <sys/stat.h>
-	//#include <netinet/in.h>
-	//#include <netinet/tcp.h>
-	//#include <arpa/inet.h>
-	#include <netdb.h>
-	#include <fcntl.h>
-	//#include <signal.h>
-	#include <errno.h>
-	#include <unistd.h>
-	#define isagain(bytes) (bytes<0 && (errno==EAGAIN || errno==EWOULDBLOCK))
-#endif
+#include "netplay_compat.h"
 
 enum
 {
diff --git a/netplay_compat.h b/netplay_compat.h
index 054f26934a..50ab01d87c 100644
--- a/netplay_compat.h
+++ b/netplay_compat.h
@@ -29,6 +29,10 @@
 #include <winsock2.h>
 #include <windows.h>
 #include <ws2tcpip.h>
+#ifndef MSG_NOSIGNAL
+#define MSG_NOSIGNAL 0
+#endif
+#define isagain(bytes) (false)
 #elif defined(_XBOX)
 #define NOD3D
 #include <xtl.h>