diff -ru pari-2.1.7.orig\src\gp\highlvl.c pari-2.1.7\src\gp\highlvl.c
--- pari-2.1.7.orig\src\gp\highlvl.c Tue Apr 23 17:29:37 2002
+++ pari-2.1.7\src\gp\highlvl.c Wed Mar 03 09:21:11 2010
@@ -18,6 +18,13 @@
 /*        SOME GP FUNCTION THAT MAY BE USEFUL OUTSIDE OF IT        */
 /*                                                                 */
 /*******************************************************************/
+
+/* we need to include windows.h quite early to avoid some macro name collisions */
+#ifdef _WIN32
+#  define WIN32_LEAN_AND_MEAN
+#  include <windows.h>
+#endif
+
 #include "pari.h"
 #ifdef macintosh
 #  include "rect.h"
--- ./src/language/es.c-pre	2002-06-23 05:49:48.000000000 -0700
+++ ./src/language/es.c	2014-06-01 10:48:39.046597000 -0700
@@ -2223,6 +2223,10 @@ os_read(long fd, char ch[], long s)
 #endif
 }
 
+#ifdef HAS_OPENDIR
+#  include <dirent.h>
+#endif
+
 long
 os_open(char *s, int mode)
 {
@@ -2259,9 +2263,6 @@ os_getenv(char *s)
 static char *last_filename = NULL;
 static char **dir_list = NULL;
 
-#ifdef HAS_OPENDIR
-#  include <dirent.h>
-#endif
 /* slow, but more portable than stat + S_I[FS]DIR */
 int
 pari_is_dir(char *name)