diff --git a/src/conio/curs_cio.c b/src/conio/curs_cio.c
index f3f6d5328b8a96055b0ca26d29e83b35956af7d2..01883602e9114a6dcbe6eeefd03fc17a5df4fdbe 100644
--- a/src/conio/curs_cio.c
+++ b/src/conio/curs_cio.c
@@ -111,7 +111,7 @@ static int _putch(unsigned char ch, BOOL refresh_now, int cp)
 	cchar_t	cha;
 	wchar_t wch[2] = {0};
 	attr_t	attr = 0;
-	short	cpair;
+	short	cpair = 0;
 
 	attr_get(&attr, &cpair, NULL);
 	attr &= ~A_COLOR;
diff --git a/src/conio/scale.c b/src/conio/scale.c
index 9849011588216f50d7867687d9a79574d4fe14d3..87c7cdfb1483e2cc566d0a35cd200e3495321eb3 100644
--- a/src/conio/scale.c
+++ b/src/conio/scale.c
@@ -1,3 +1,4 @@
+#include <math.h>
 #include <stdbool.h>
 #include <stdlib.h>
 
diff --git a/src/conio/x_events.c b/src/conio/x_events.c
index ce352d7e985a6529986a76d23ae44631b13f0e63..6ac3fb35bf1c270fd10a6e99f5d58a188e07a528 100644
--- a/src/conio/x_events.c
+++ b/src/conio/x_events.c
@@ -3,6 +3,7 @@
  * event thread.
  */
  
+#include <math.h>
 #include <unistd.h>
 #include <stdbool.h>
 
diff --git a/src/syncterm/bbslist.c b/src/syncterm/bbslist.c
index 281824509061fa15bf438964c4fbd42ae0624a85..e5d950794c8d35e4d92f561f48d23083d52cd5f7 100644
--- a/src/syncterm/bbslist.c
+++ b/src/syncterm/bbslist.c
@@ -7,6 +7,7 @@
 #include <dirwrap.h>
 #include <ini_file.h>
 #include <uifc.h>
+#include <xpprintf.h>
 #include "filepick.h"
 
 #include "syncterm.h"
diff --git a/src/syncterm/ripper.c b/src/syncterm/ripper.c
index 1c1a574e7880d837efe71f5e0254b8c846025274..b406d0817a84a6ab59d2514670508d4ff7b37d18 100644
--- a/src/syncterm/ripper.c
+++ b/src/syncterm/ripper.c
@@ -23,6 +23,7 @@
 #if defined(__unix__)
 	#include <unistd.h>
 #endif
+#include <time.h>
 #include <vidmodes.h>
 #include <xpbeep.h>
 
diff --git a/src/xpdev/strwrap.h b/src/xpdev/strwrap.h
index f30d54e450e68bd45cae618ca9b2cf22e2b2610f..e52986f122e4baa1a5fe5ec95b0fd4daa36fdf1d 100644
--- a/src/xpdev/strwrap.h
+++ b/src/xpdev/strwrap.h
@@ -18,7 +18,7 @@ char* ltoa(long val, char* str, int radix);
 
 #endif
 
-#ifdef _MSVC
+#if defined(_MSC_VER) || defined(__MSVCRT__)
 #if defined(__cplusplus)
 extern "C" {
 #endif