diff --git a/binding-mri/binding-util.h b/binding-mri/binding-util.h index 83589f7..2d4a218 100644 --- a/binding-mri/binding-util.h +++ b/binding-mri/binding-util.h @@ -23,6 +23,7 @@ #define BINDING_UTIL_H #include +#undef inline //ruby's config.h has #define inline __inline, which cause error in xkeycheck.h #include "exception.h" diff --git a/binding-mri/table-binding.cpp b/binding-mri/table-binding.cpp index 87a9b58..17b64a3 100644 --- a/binding-mri/table-binding.cpp +++ b/binding-mri/table-binding.cpp @@ -19,6 +19,10 @@ ** along with mkxp. If not, see . */ +#ifdef _MSC_VER +#define NOMINMAX +#endif + #include #include "table.h" #include "binding-util.h" diff --git a/src/alstream.cpp b/src/alstream.cpp index 18799ff..3220fd4 100644 --- a/src/alstream.cpp +++ b/src/alstream.cpp @@ -19,6 +19,7 @@ ** along with mkxp. If not, see . */ +#include "crossplatform.h" #include "alstream.h" #include "sharedstate.h" diff --git a/src/config.cpp b/src/config.cpp index cbbbe99..5db26f5 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -348,7 +348,11 @@ void Config::readGameINI() size_t inLen = game.title.size(); size_t outLen = inLen * 4; std::string buf(outLen, '\0'); +#ifdef _MSC_VER + const char *inPtr = game.title.c_str(); +#else char *inPtr = const_cast(game.title.c_str()); +#endif char *outPtr = const_cast(buf.c_str()); errno = 0; diff --git a/src/crossplatform.h b/src/crossplatform.h new file mode 100644 index 0000000..26f4993 --- /dev/null +++ b/src/crossplatform.h @@ -0,0 +1,17 @@ +#ifndef MKXP_CROSSPLATFORM_H +#define MKXP_CROSSPLATFORM_H + +#ifdef _MSC_VER +//#define _CRT_SECURE_NO_DEPRECATE //should be defined in binding-mri's preprocessor for vsnprintf, fopen + +#include + +#ifndef snprintf +#define snprintf _snprintf +#endif +#ifndef chdir +#define chdir _chdir +#endif +#endif + +#endif //MKXP_CROSSPLATFORM_H diff --git a/src/eventthread.cpp b/src/eventthread.cpp index df381e8..864de9b 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -19,6 +19,7 @@ ** along with mkxp. If not, see . */ +#include "crossplatform.h" #include "eventthread.h" #include diff --git a/src/exception.h b/src/exception.h index 47d9c78..02db28e 100644 --- a/src/exception.h +++ b/src/exception.h @@ -22,6 +22,8 @@ #ifndef EXCEPTION_H #define EXCEPTION_H +#include "crossplatform.h" + #include #include #include diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 6642d3b..3dc2119 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -19,6 +19,7 @@ ** along with mkxp. If not, see . */ +#include "crossplatform.h" #include "filesystem.h" #include "rgssad.h" diff --git a/src/graphics.cpp b/src/graphics.cpp index 1862629..a5ae7bc 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -43,7 +43,9 @@ #include #include +#ifndef _MSC_VER #include +#endif #include #include diff --git a/src/keybindings.cpp b/src/keybindings.cpp index 49d2a71..4a89fb6 100644 --- a/src/keybindings.cpp +++ b/src/keybindings.cpp @@ -19,6 +19,7 @@ ** along with mkxp. If not, see . */ +#include "crossplatform.h" #include "keybindings.h" #include "config.h" diff --git a/src/main.cpp b/src/main.cpp index eb07970..0c34a68 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,11 +26,14 @@ #include #include +#ifndef _MSC_VER #include +#endif #include #include #include +#include "crossplatform.h" #include "sharedstate.h" #include "eventthread.h" #include "gl-debug.h" @@ -357,4 +360,4 @@ int main(int argc, char *argv[]) SDL_Quit(); return 0; -} +} \ No newline at end of file diff --git a/src/settingsmenu.cpp b/src/settingsmenu.cpp index a14b488..fe95674 100644 --- a/src/settingsmenu.cpp +++ b/src/settingsmenu.cpp @@ -19,6 +19,7 @@ ** along with mkxp. If not, see . */ +#include "crossplatform.h" #include "settingsmenu.h" #include diff --git a/src/sharedstate.cpp b/src/sharedstate.cpp index 023ff6b..4c29f87 100644 --- a/src/sharedstate.cpp +++ b/src/sharedstate.cpp @@ -38,7 +38,9 @@ #include "exception.h" #include "sharedmidistate.h" +#ifndef _MSC_VER #include +#endif #include #include diff --git a/src/soundemitter.cpp b/src/soundemitter.cpp index 3850c0b..c27ef15 100644 --- a/src/soundemitter.cpp +++ b/src/soundemitter.cpp @@ -19,6 +19,7 @@ ** along with mkxp. If not, see . */ +#include "crossplatform.h" #include "soundemitter.h" #include "sharedstate.h" diff --git a/src/util.h b/src/util.h index ad9141a..214d057 100644 --- a/src/util.h +++ b/src/util.h @@ -22,6 +22,8 @@ #ifndef UTIL_H #define UTIL_H +#include "crossplatform.h" + #include #include #include