Character type fixes for building with clang-cl

This commit is contained in:
Ben Payne 2015-03-04 18:40:16 -05:00
parent 01471c9ef3
commit 4386ababbe
2 changed files with 12 additions and 2 deletions

View file

@ -54,7 +54,17 @@ struct EmptyType {}; ///< "Null" type used by templates
//////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef char UTF8; ///< Compiler independent 8 bit Unicode encoded character
#if defined(_MSC_VER) && defined(__clang__)
// Clang's MSVC compatibility mode doesn't currently support /Zc:wchar_t-,
// which we rely on to avoid type conversion errors when calling system
// APIs when wchar_t is defined as unsigned short. So, just define UTF16
// as wchar_t instead since it's always a 2 byte unsigned on windows anyway.
typedef wchar_t UTF16;
#else
typedef unsigned short UTF16; ///< Compiler independent 16 bit Unicode encoded character
#endif
typedef unsigned int UTF32; ///< Compiler independent 32 bit Unicode encoded character
typedef const char* StringTableEntry;

View file

@ -137,14 +137,14 @@ static void _keyboardEvent(Win32Window* window,UINT message, WPARAM wParam, WPAR
&& window->getKeyboardTranslation()
&& !window->shouldNotTranslate( torqueMods, newVirtKey ) )
{
U16 chars[ 64 ];
wchar_t chars[ 64 ];
dMemset( chars, 0, sizeof( chars ) );
S32 res = ToUnicode( keyCode, scanCode, keyboardState, chars, sizeof( chars ) / sizeof( chars[ 0 ] ), 0 );
// This should only happen on Window 9x/ME systems
if( res == 0 )
res = ToAscii( keyCode, scanCode, keyboardState, chars, 0 );
res = ToAscii( keyCode, scanCode, keyboardState, (LPWORD)chars, 0 );
if( res >= 1 )
{