(svn r10778) -Fix: one-liners to allow MSVC and WINCE to work together (or anyway, a step towards that goal)
authortruelight
Fri, 03 Aug 2007 23:26:12 +0000
changeset 7405 2fd57f130eca
parent 7404 70543a7025e0
child 7406 69bfb4b909e8
(svn r10778) -Fix: one-liners to allow MSVC and WINCE to work together (or anyway, a step towards that goal)
-Fix: put DEBUG lines under WINCE via a function designed for just that under WINCE
src/debug.cpp
src/map.cpp
src/minilzo.cpp
src/misc/strapi.hpp
src/os_timer.cpp
src/stdafx.h
--- a/src/debug.cpp	Fri Aug 03 23:19:29 2007 +0000
+++ b/src/debug.cpp	Fri Aug 03 23:26:12 2007 +0000
@@ -94,7 +94,14 @@
 		} else
 #endif /* ENABLE_NETWORK */
 		{
+#if defined(WINCE)
+			/* We need to do OTTD2FS twice, but as it uses a static buffer, we need to store one temporary */
+			TCHAR tbuf[512];
+			_sntprintf(tbuf, sizeof(tbuf), _T("%s"), OTTD2FS(dbg));
+			NKDbgPrintfW(_T("dbg: [%s] %s\n"), tbuf, OTTD2FS(buf));
+#else
 			fprintf(stderr, "dbg: [%s] %s\n", dbg, buf);
+#endif
 			IConsoleDebug(dbg, buf);
 		}
 	}
--- a/src/map.cpp	Fri Aug 03 23:19:29 2007 +0000
+++ b/src/map.cpp	Fri Aug 03 23:26:12 2007 +0000
@@ -84,7 +84,7 @@
 
 		snprintf(buf, lengthof(buf), "TILE_ADD(%s) when adding 0x%.4X and 0x%.4X failed",
 			exp, tile, add);
-#if !defined(_MSC_VER)
+#if !defined(_MSC_VER) || defined(WINCE)
 		fprintf(stderr, "%s:%d %s\n", file, line, buf);
 #else
 		_assert(buf, (char*)file, line);
--- a/src/minilzo.cpp	Fri Aug 03 23:19:29 2007 +0000
+++ b/src/minilzo.cpp	Fri Aug 03 23:26:12 2007 +0000
@@ -60,7 +60,7 @@
 #  define LZO_HAVE_CONFIG_H
 #endif
 
-#if !defined(LZO_NO_SYS_TYPES_H)
+#if !defined(LZO_NO_SYS_TYPES_H) && !defined(WINCE)
 #  include <sys/types.h>
 #endif
 #include <stdio.h>
--- a/src/misc/strapi.hpp	Fri Aug 03 23:19:29 2007 +0000
+++ b/src/misc/strapi.hpp	Fri Aug 03 23:26:12 2007 +0000
@@ -38,7 +38,7 @@
 /** ::vsprintf wrapper specialization for char */
 template <> /*static*/ inline int CStrApiBaseT<char>::SPrintFL(char *buf, size_t count, const char *fmt, va_list args)
 {
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) // VC 8.0 and above
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(WINCE) // VC 8.0 and above
 	return ::vsnprintf_s(buf, count, count - 1, fmt, args);
 #else /* ! VC 8.0 and above */
 	return ::vsnprintf(buf, count, fmt, args);
@@ -55,7 +55,7 @@
 /** ::vsprintf wrapper specialization for wchar_t */
 template <> /*static*/ inline int CStrApiBaseT<wchar_t>::SPrintFL(wchar_t *buf, size_t count, const wchar_t *fmt, va_list args)
 {
-#if defined(_MSC_VER) && (_MSC_VER >= 1400) // VC 8.0 and above
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(WINCE) // VC 8.0 and above
 	return ::_vsnwprintf_s(buf, count, count - 1, fmt, args);
 #else /* ! VC 8.0 and above */
 # if defined(_WIN32)
--- a/src/os_timer.cpp	Fri Aug 03 23:19:29 2007 +0000
+++ b/src/os_timer.cpp	Fri Aug 03 23:26:12 2007 +0000
@@ -8,7 +8,7 @@
 
 /* rdtsc for MSC_VER, uses simple inline assembly, or _rdtsc
  * from external win64.asm because VS2005 does not support inline assembly */
-#if defined(_MSC_VER) && !defined(RDTSC_AVAILABLE)
+#if defined(_MSC_VER) && !defined(RDTSC_AVAILABLE) && !defined(WINCE)
 # if _MSC_VER >= 1400
 #include <intrin.h>
 uint64 _rdtsc()
@@ -71,6 +71,9 @@
 /* In all other cases we have no support for rdtsc. No major issue,
  * you just won't be able to profile your code with TIC()/TOC() */
 #if !defined(RDTSC_AVAILABLE)
+/* MSVC (in case of WinCE) can't handle #warning */
+# if !defined(_MSC_VER)
 #warning "(non-fatal) No support for rdtsc(), you won't be able to profile with TIC/TOC"
+# endif
 uint64 _rdtsc() {return 0;}
 #endif
--- a/src/stdafx.h	Fri Aug 03 23:19:29 2007 +0000
+++ b/src/stdafx.h	Fri Aug 03 23:26:12 2007 +0000
@@ -142,7 +142,9 @@
 # define _WIN32_WINNT 0x0500       // Windows 2000
 
 # define _WIN32_WINDOWS 0x400      // Windows 95
+#if !defined(WINCE)
 # define WINVER 0x0400             // Windows NT 4.0 / Windows 95
+#endif
 # define _WIN32_IE_ 0x0401         // 4.01 (win98 and NT4SP5+)
 
 # define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
@@ -168,9 +170,11 @@
 # define NORETURN __declspec(noreturn)
 # define FORCEINLINE __forceinline
 # define inline _inline
-# define CDECL _cdecl
+# if !defined(WINCE)
+#  define CDECL _cdecl
+# endif
   int CDECL snprintf(char *str, size_t size, const char *format, ...);
-# if _MSC_VER < 1400
+# if _MSC_VER < 1400 || defined(WINCE)
    int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
 # endif
 
@@ -191,8 +195,14 @@
 #  endif
 # endif
 
-# define strcasecmp stricmp
-# define strncasecmp strnicmp
+# if defined(WINCE)
+#  define strcasecmp _stricmp
+#  define strncasecmp _strnicmp
+#  undef DEBUG
+# else
+#  define strcasecmp stricmp
+#  define strncasecmp strnicmp
+# endif
 /* suppress: warning C4005: 'offsetof' : macro redefinition (VC8) */
 #endif /* defined(_MSC_VER) */