(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
pull/155/head
truelight 17 years ago
parent c02d8ebb09
commit 930bb84242

@ -94,7 +94,14 @@ void CDECL debug(const char *dbg, ...)
} 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);
}
}

@ -84,7 +84,7 @@ TileIndex TileAdd(TileIndex tile, TileIndexDiff add,
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);

@ -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>

@ -38,7 +38,7 @@ template <> /*static*/ inline size_t CStrApiBaseT<char>::StrLen(const char *s)
/** ::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 @@ template <> /*static*/ inline size_t CStrApiBaseT<wchar_t>::StrLen(const wchar_t
/** ::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)

@ -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 @@ uint64 _rdtsc()
/* 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

@ -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) */

Loading…
Cancel
Save