diff --git a/src/xpdev/sdlfuncs.c b/src/xpdev/sdlfuncs.c
index fb943ea057e5e0f9d1ae786b1da9e6fee15dab51..07cf72aab69c35ed572da4f036d2f6886b5515db 100644
--- a/src/xpdev/sdlfuncs.c
+++ b/src/xpdev/sdlfuncs.c
@@ -4,7 +4,14 @@
 #include <dlfcn.h>
 #endif
 
+#include <SDL.h>
+#ifndef main
+ #define USE_REAL_MAIN
+#endif
 #include "gen_defs.h"
+#ifdef USE_REAL_MAIN
+ #undef main
+#endif
 #include "sdlfuncs.h"
 
 #ifndef _WIN32