diff --git a/Source/lineparse.cpp b/Source/lineparse.cpp index a4fbe38e..8a824c5e 100644 --- a/Source/lineparse.cpp +++ b/Source/lineparse.cpp @@ -22,6 +22,7 @@ #include #include #include "tstring.h" +#include "util.h" LineParser::LineParser(bool bCommentBlock) { diff --git a/Source/tchar.h b/Source/tchar.h index 7f2e998d..34dbe660 100644 --- a/Source/tchar.h +++ b/Source/tchar.h @@ -22,8 +22,13 @@ #define _T(x) __T(x) #define _TEXT(x) __T(x) #endif +#if defined(_MSC_VER) && (_MSC_VER<=1200) +typedef unsigned short TCHAR; +typedef unsigned short _TUCHAR; +#else typedef wchar_t TCHAR; typedef wchar_t _TUCHAR; +#endif // program #define _tmain wmain @@ -34,11 +39,19 @@ typedef wchar_t _TUCHAR; // printfs #define _ftprintf fwprintf #define _sntprintf _snwprintf -#define _stprintf _swprintf +#if defined(_MSC_VER) && (_MSC_VER<=1200) +# define _stprintf swprintf +#else +# define _stprintf _swprintf +#endif #define _tprintf wprintf #define _vftprintf vfwprintf #define _vsntprintf _vsnwprintf -#define _vstprintf _vswprintf +#if defined(_MSC_VER) && (_MSC_VER<=1200) +# define _vstprintf vswprintf +#else +# define _vstprintf _vswprintf +#endif // scanfs #define _tscanf wscanf @@ -74,7 +87,11 @@ typedef wchar_t _TUCHAR; #define _tcstoi64 _wcstoi64 #define _tcstol wcstol #define _tcstoul wcstoul -#define _tstof _wtof +#if defined(_MSC_VER) && (_MSC_VER<=1200) +# define _tstof my_wtof +#else +# define _tstof _wtof +#endif #define _tstoi _wtoi #define _tstoi64 _wtoi64 #define _ttoi _wtoi diff --git a/Source/util.cpp b/Source/util.cpp index 08ab55f0..afce0508 100644 --- a/Source/util.cpp +++ b/Source/util.cpp @@ -65,6 +65,14 @@ void dopause(void) } } +double my_wtof(const wchar_t *str) +{ + char buf[100]; + WideCharToMultiByte(0,0,str,-1,buf,100,0,0); + return atof(buf); +} + + // Returns 0 if everything is OK // Returns -1 if can't find the file // Returns -2 if the file is an invalid bitmap diff --git a/Source/util.h b/Source/util.h index 49bf1bdf..5bed0f74 100644 --- a/Source/util.h +++ b/Source/util.h @@ -34,6 +34,8 @@ extern int g_dopause; extern void dopause(void); +extern double my_wtof(const wchar_t *str); + // Adds the bitmap in filename using resource editor re as id id. // If width or height are specified it will also make sure the bitmap is in that size int update_bitmap(CResourceEditor* re, WORD id, const TCHAR* filename, int width=0, int height=0, int maxbpp=0);