WIN32 -> _WIN32; see http://predef.sourceforge.net/preos.html#sec25
diff --git a/asn1c/asn1c.c b/asn1c/asn1c.c
index 08a3690..4c565e4 100644
--- a/asn1c/asn1c.c
+++ b/asn1c/asn1c.c
@@ -42,7 +42,7 @@
 
 #include <asn1c_compat.h>	/* Portable basename(3) and dirname(3) */
 
-#ifdef	WIN32
+#ifdef	_WIN32
 #include <io.h>
 #include <direct.h>
 #else
@@ -345,7 +345,7 @@
 	char *target_dir;
 	int target_dir_len;
 	int len;
-#ifdef	WIN32
+#ifdef	_WIN32
 	intptr_t dir;
 	struct _finddata_t c_file;
 	char *pattern;
@@ -369,7 +369,7 @@
 	snprintf(target_dir, target_dir_len + 1, "%s/standard-modules",
 		skeletons_dir);
 
-#ifdef	WIN32
+#ifdef	_WIN32
 	len = target_dir_len + sizeof("/*.asn1");
 	pattern = malloc(len);
 	assert(pattern);
@@ -386,7 +386,7 @@
 		return -1;
 	}
 
-#ifdef	WIN32
+#ifdef	_WIN32
 	do {
 		filename = c_file.name;
 #else
@@ -416,7 +416,7 @@
 		}
 		asn1p_delete(new_asn);
 
-#ifdef	WIN32
+#ifdef	_WIN32
 	} while(_findnext(dir, &c_file) == 0);
 	_findclose(dir);
 #else
diff --git a/asn1c/sys-common.h b/asn1c/sys-common.h
index 514a20c..cac71c0 100644
--- a/asn1c/sys-common.h
+++ b/asn1c/sys-common.h
@@ -46,9 +46,9 @@
 #include <sys/stat.h>		/* for stat(2) */
 #endif
 
-#ifndef	WIN32
+#ifndef	_WIN32
 #include <sysexits.h>		/* for EX_USAGE & others */
-#else	/* WIN32 */
+#else	/* _WIN32 */
 #ifndef	EX_USAGE
 #define	EX_USAGE 64
 #endif
@@ -66,5 +66,5 @@
 #endif
 #define	alloca _alloca
 #define	snprintf _snprintf
-#endif	/* WIN32 */
+#endif	/* _WIN32 */
 
diff --git a/asn1c/webcgi/asn1c-suid-helper.c b/asn1c/webcgi/asn1c-suid-helper.c
index a334f1f..d987c7a 100644
--- a/asn1c/webcgi/asn1c-suid-helper.c
+++ b/asn1c/webcgi/asn1c-suid-helper.c
@@ -6,7 +6,7 @@
 #include <errno.h>
 #include <sysexits.h>
 
-#ifdef	WIN32
+#ifdef	_WIN32
 #define setuid(s)
 #define getuid()
 #define setgid(s)
diff --git a/libasn1compiler/asn1c_compat.c b/libasn1compiler/asn1c_compat.c
index 17dd906..724124c 100644
--- a/libasn1compiler/asn1c_compat.c
+++ b/libasn1compiler/asn1c_compat.c
@@ -6,7 +6,7 @@
 #endif
 
 #ifndef	DEFFILEMODE	/* Normally in <sys/stat.h> */
-#ifdef	WIN32
+#ifdef	_WIN32
 #define	DEFFILEMODE	(S_IREAD|S_IWRITE)
 #else
 #define	DEFFILEMODE	(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
@@ -21,7 +21,7 @@
 FILE *
 asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
 	int created = 1;
-#ifndef	WIN32
+#ifndef	_WIN32
 	struct stat sb;
 #endif
 	char *fname;
@@ -44,7 +44,7 @@
 		 * Create temporary file.
 		 */
 		fd = mkstemp(fname);
-#ifndef	WIN32
+#ifndef	_WIN32
 		(void)fchmod(fd, DEFFILEMODE);
 #endif
 	} else {
@@ -62,7 +62,7 @@
 		return NULL;
 	}
 
-#ifndef	WIN32
+#ifndef	_WIN32
 	/*
 	 * Check sanity.
 	 */
@@ -76,7 +76,7 @@
 	(void)ftruncate(fd, 0);
 #else
 	_chsize(fd, 0);
-#endif	/* WIN32 */
+#endif	/* _WIN32 */
 
 	/*
 	 * Convert file descriptor into file pointer.
diff --git a/libasn1compiler/asn1c_internal.h b/libasn1compiler/asn1c_internal.h
index fb8cc1e..f97a40b 100644
--- a/libasn1compiler/asn1c_internal.h
+++ b/libasn1compiler/asn1c_internal.h
@@ -22,7 +22,7 @@
 #include <unistd.h>		/* for unlink(2) */
 #endif
 
-#ifdef	WIN32
+#ifdef	_WIN32
 #include <io.h>
 #include <malloc.h>
 #include <fcntl.h>
diff --git a/libasn1compiler/asn1c_save.c b/libasn1compiler/asn1c_save.c
index f348f19..2a01b41 100644
--- a/libasn1compiler/asn1c_save.c
+++ b/libasn1compiler/asn1c_save.c
@@ -356,7 +356,7 @@
 	size_t olen, nlen;
 	int retval = 1;	/* Files are identical */
 
-#ifndef	WIN32
+#ifndef	_WIN32
 	struct stat sb;
 
 	if(lstat(fname1, &sb) || !S_ISREG(sb.st_mode)
@@ -431,7 +431,7 @@
 static int
 asn1c_copy_over(arg_t *arg, char *path) {
 	char *fname;
-#ifdef	WIN32
+#ifdef	_WIN32
 	int use_real_copy = 1;
 #else
 	int use_real_copy = (arg->flags & A1C_SKELETONS_COPY);
diff --git a/libasn1fix/asn1fix_internal.h b/libasn1fix/asn1fix_internal.h
index 612b718..3ccae81 100644
--- a/libasn1fix/asn1fix_internal.h
+++ b/libasn1fix/asn1fix_internal.h
@@ -23,7 +23,7 @@
 #include <asn1parser.h>		/* Our lovely ASN.1 parser module */
 #include "asn1fix.h"
 
-#ifdef	WIN32
+#ifdef	_WIN32
 #define	EX_NOINPUT	66
 #define	EX_DATAERR	65
 #define	snprintf	_snprintf
diff --git a/libasn1fix/check_fixer.c b/libasn1fix/check_fixer.c
index 51e5bbf..3d5793e 100644
--- a/libasn1fix/check_fixer.c
+++ b/libasn1fix/check_fixer.c
@@ -1,7 +1,7 @@
 #undef	NDEBUG
 #include "asn1fix_internal.h"
 
-#ifdef	WIN32
+#ifdef	_WIN32
 #include <io.h>
 #include <direct.h>
 #define	chdir _chdir
@@ -21,7 +21,7 @@
 
 int
 main(int ac, char **av) {
-#ifdef	WIN32
+#ifdef	_WIN32
 	intptr_t dir;
 	struct _finddata_t c_file;
 #else
@@ -53,13 +53,13 @@
 		fprintf(stderr, "Testing in ./tests...\n");
 		ret = chdir("../tests");
 		assert(ret == 0);
-#ifdef	WIN32
+#ifdef	_WIN32
 		dir = _findfirst("*.asn1", &c_file);
 		assert(dir != -1L);
 #else
 		dir = opendir(".");
 		assert(dir);
-#endif	/* WIN32 */
+#endif	/* _WIN32 */
 	} else {
 		dir = 0;
 	}
@@ -68,13 +68,13 @@
 	 * Scan every *.asn1 file and try to parse and fix it.
 	 */
 	if(dir) {
-#ifdef	WIN32
+#ifdef	_WIN32
 		do {
 			filename = c_file.name;
 #else
 		while((dp = readdir(dir))) {
 			filename = dp->d_name;
-#endif	/* WIN32 */
+#endif	/* _WIN32 */
 			len = strlen(filename);
 			if(len <= 5 || strcmp(filename + len - 5, ".asn1"))
 				continue;
@@ -85,13 +85,13 @@
 				failed++;
 			}
 			completed++;
-#ifdef	WIN32
+#ifdef	_WIN32
 		} while(_findnext(dir, &c_file) == 0);
 		_findclose(dir);
 #else
 		}
 		closedir(dir);
-#endif	/* WIN32 */
+#endif	/* _WIN32 */
 
 
 		fprintf(stderr,
diff --git a/libasn1parser/asn1parser.c b/libasn1parser/asn1parser.c
index 7d9a88d..2ade9e9 100644
--- a/libasn1parser/asn1parser.c
+++ b/libasn1parser/asn1parser.c
@@ -69,7 +69,7 @@
  */
 asn1p_t *
 asn1p_parse_file(const char *filename, enum asn1p_flags flags) {
-#ifndef	WIN32
+#ifndef	_WIN32
 	struct stat sb;
 #endif
 	asn1p_t *a = 0;
@@ -88,7 +88,7 @@
 		return NULL;
 	}
 
-#ifndef	WIN32
+#ifndef	_WIN32
 	if(fstat(fileno(fp), &sb)
 	|| !S_ISREG(sb.st_mode)) {
 		fclose(fp);
@@ -97,7 +97,7 @@
 		errno = EINVAL;
 		return NULL;
 	}
-#endif	/* WIN32 */
+#endif	/* _WIN32 */
 
 	asn1p_lineno = 1;
 
diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c
index 9d683ef..1a16ba8 100644
--- a/skeletons/GeneralizedTime.c
+++ b/skeletons/GeneralizedTime.c
@@ -14,7 +14,7 @@
 #include <time.h>
 #endif	/* __CYGWIN__ */
 
-#if	defined(WIN32)
+#if	defined(_WIN32)
 #pragma message( "PLEASE STOP AND READ!")
 #pragma message( "  localtime_r is implemented via localtime(), which may be not thread-safe.")
 #pragma message( "  gmtime_r is implemented via gmtime(), which may be not thread-safe.")
@@ -41,7 +41,7 @@
 #define	putenv(c)	_putenv(c)
 #define	_EMULATE_TIMEGM
 
-#endif	/* WIN32 */
+#endif	/* _WIN32 */
 
 #if	defined(sun) || defined(_sun_) || defined(__solaris__)
 #define	_EMULATE_TIMEGM
diff --git a/skeletons/asn_system.h b/skeletons/asn_system.h
index 0a9b092..d391b7b 100644
--- a/skeletons/asn_system.h
+++ b/skeletons/asn_system.h
@@ -21,7 +21,7 @@
 #include <stdarg.h>	/* For va_start */
 #include <stddef.h>	/* for offsetof and ptrdiff_t */
 
-#ifdef	WIN32
+#ifdef	_WIN32
 
 #include <malloc.h>
 #define	 snprintf	_snprintf
@@ -46,7 +46,7 @@
 typedef	unsigned short	uint16_t;
 typedef	unsigned int	uint32_t;
 #endif	/* ASSUMESTDTYPES */
-#define WIN32_LEAN_AND_MEAN
+#define _WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <float.h>
 #define isnan _isnan
@@ -57,7 +57,7 @@
 #include <stdint.h>
 #endif	/* _MSC_VER */
 
-#else	/* !WIN32 */
+#else	/* !_WIN32 */
 
 #if defined(__vxworks)
 #include <types/vxTypes.h>
@@ -90,7 +90,7 @@
 
 #endif	/* defined(__vxworks) */
 
-#endif	/* WIN32 */
+#endif	/* _WIN32 */
 
 #if	__GNUC__ >= 3
 #ifndef	GCC_PRINTFLIKE