Kaynağa Gözat

Character type fixes for building with clang-cl

Ben Payne 10 yıl önce
ebeveyn
işleme
4386ababbe

+ 10 - 0
Engine/source/platform/types.h

@@ -54,7 +54,17 @@ struct EmptyType {};                ///< "Null" type used by templates
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
 typedef char           UTF8;        ///< Compiler independent 8  bit Unicode encoded character
 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
 typedef unsigned short UTF16;       ///< Compiler independent 16 bit Unicode encoded character
+#endif
+
 typedef unsigned int   UTF32;       ///< Compiler independent 32 bit Unicode encoded character
 typedef unsigned int   UTF32;       ///< Compiler independent 32 bit Unicode encoded character
 
 
 typedef const char* StringTableEntry;
 typedef const char* StringTableEntry;

+ 2 - 2
Engine/source/windowManager/win32/winDispatch.cpp

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