From 363b86539ff90c7a003ab9c4fdf1cf039a5dc183 Mon Sep 17 00:00:00 2001 From: doyle Date: Fri, 25 Aug 2023 23:49:03 +1000 Subject: [PATCH] dqn: Re-enable clang build flags --- Misc/dqn_unit_tests.cpp | 8 ++++---- build.bat | 15 +++++++-------- dqn_platform.cpp | 4 ++-- dqn_platform.h | 4 ++-- dqn_strings.cpp | 4 ++-- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Misc/dqn_unit_tests.cpp b/Misc/dqn_unit_tests.cpp index c1da23e..9b18be2 100644 --- a/Misc/dqn_unit_tests.cpp +++ b/Misc/dqn_unit_tests.cpp @@ -1770,8 +1770,8 @@ Dqn_UTest TestWin() int size_returned = Dqn_Win_String8ToString16Buffer(INPUT, nullptr, 0); wchar_t const EXPECTED[] = {L'S', L't', L'r', L'i', L'n', L'g', 0}; - DQN_UTEST_ASSERTF(&test, string16.size == size_returned, "string_size: %d, result: %d", DQN_CAST(int)string16.size, size_returned); - DQN_UTEST_ASSERTF(&test, string16.size == DQN_ARRAY_UCOUNT(EXPECTED) - 1, "string_size: %d, expected: %zu", DQN_CAST(int)string16.size, DQN_ARRAY_UCOUNT(EXPECTED) - 1); + DQN_UTEST_ASSERTF(&test, DQN_CAST(int)string16.size == size_returned, "string_size: %d, result: %d", DQN_CAST(int)string16.size, size_returned); + DQN_UTEST_ASSERTF(&test, DQN_CAST(int)string16.size == DQN_ARRAY_UCOUNT(EXPECTED) - 1, "string_size: %d, expected: %zu", DQN_CAST(int)string16.size, DQN_ARRAY_UCOUNT(EXPECTED) - 1); DQN_UTEST_ASSERT(&test, DQN_MEMCMP(EXPECTED, string16.data, sizeof(EXPECTED)) == 0); } @@ -1783,8 +1783,8 @@ Dqn_UTest TestWin() int size_returned = Dqn_Win_String16ToString8Buffer(INPUT, nullptr, 0); char const EXPECTED[] = {'S', 't', 'r', 'i', 'n', 'g', 0}; - DQN_UTEST_ASSERTF(&test, string8.size == size_returned, "string_size: %d, result: %d", DQN_CAST(int)string8.size, size_returned); - DQN_UTEST_ASSERTF(&test, string8.size == DQN_ARRAY_UCOUNT(EXPECTED) - 1, "string_size: %d, expected: %zu", DQN_CAST(int)string8.size, DQN_ARRAY_UCOUNT(EXPECTED) - 1); + DQN_UTEST_ASSERTF(&test, DQN_CAST(int)string8.size == size_returned, "string_size: %d, result: %d", DQN_CAST(int)string8.size, size_returned); + DQN_UTEST_ASSERTF(&test, DQN_CAST(int)string8.size == DQN_ARRAY_UCOUNT(EXPECTED) - 1, "string_size: %d, expected: %zu", DQN_CAST(int)string8.size, DQN_ARRAY_UCOUNT(EXPECTED) - 1); DQN_UTEST_ASSERT(&test, DQN_MEMCMP(EXPECTED, string8.data, sizeof(EXPECTED)) == 0); } } diff --git a/build.bat b/build.bat index 8f6abdd..4a0b1de 100644 --- a/build.bat +++ b/build.bat @@ -4,8 +4,7 @@ setlocal set code_dir=%~dp0 if not exist Build mkdir Build pushd Build - - REM Flags ================================================================== + REM Flags ====================================================================================== REM MT Static CRT REM EHa- Disable exception handling REM GR- Disable C RTTI @@ -14,22 +13,22 @@ pushd Build REM Z7 Combine multi-debug files to one debug file REM wd4201 Nonstandard extension used: nameless struct/union REM Tp Treat header file as CPP source file - set compile_flags=-MT -EHa -GR- -Od -Oi -Z7 -wd4201 -W4 -WX -D DQN_TEST_WITH_MAIN -nologo -analyze - set linker_flags=-link -nologo - set msvc_flags=-fsanitize=address + set compile_flags=-MT -EHa -GR- -Od -Oi -Z7 -wd4201 -W4 -WX -D DQN_TEST_WITH_MAIN -nologo + set link_flags=-link + set msvc_flags=-fsanitize=address -analyze set clang_flags=-fsanitize=address,undefined - REM Compiler: MSVC cl ====================================================== + REM Compiler: MSVC cl ========================================================================== where /q cl || ( echo [ERROR] cl is not found, please put MSVC's cl on the path exit /b 1 ) cl %compile_flags% %msvc_flags% %code_dir%\Misc\dqn_unit_tests.cpp -I %code_dir% /Fe:dqn_unit_tests_msvc %link_flags% || exit /b 1 - REM Compiler: clang-cl ===================================================== + REM Compiler: clang-cl ========================================================================= where /q clang-cl || ( echo [WARN] Optional clang compile via clang-cl if it's in the path, please put clang-cl on the path for this feature exit /b 0 ) - clang-cl -D DQN_TEST_WITH_MAIN %code_dir%\Misc\dqn_unit_tests.cpp -I %code_dir% /Fe:dqn_unit_tests_clang -link + clang-cl %compile_flags% %clang_flags% %code_dir%\Misc\dqn_unit_tests.cpp -I %code_dir% /Fe:dqn_unit_tests_clang %link_flags% || exit /b 1 popd diff --git a/dqn_platform.cpp b/dqn_platform.cpp index c571fab..e92cd0d 100644 --- a/dqn_platform.cpp +++ b/dqn_platform.cpp @@ -1195,7 +1195,7 @@ DQN_API Dqn_String16 Dqn_Win_String8ToString16(Dqn_Arena *arena, Dqn_String8 src return result; } -DQN_API int Dqn_Win_String8ToString16Buffer(Dqn_String8 src, wchar_t *dest, Dqn_usize dest_size) +DQN_API int Dqn_Win_String8ToString16Buffer(Dqn_String8 src, wchar_t *dest, int dest_size) { int result = 0; if (!Dqn_String8_IsValid(src)) @@ -1211,7 +1211,7 @@ DQN_API int Dqn_Win_String8ToString16Buffer(Dqn_String8 src, wchar_t *dest, Dqn_ } // NOTE: Windows String16 To UTF8 ================================================================== -DQN_API int Dqn_Win_String16ToString8Buffer(Dqn_String16 src, char *dest, Dqn_usize dest_size) +DQN_API int Dqn_Win_String16ToString8Buffer(Dqn_String16 src, char *dest, int dest_size) { int result = 0; if (!Dqn_String8_IsValid(src)) diff --git a/dqn_platform.h b/dqn_platform.h index 24f8fc5..cdd4413 100644 --- a/dqn_platform.h +++ b/dqn_platform.h @@ -307,9 +307,9 @@ DQN_API void Dqn_Win_MakeProcessDPIAware(); // queried using 'Dqn_Win_LastError' DQN_API Dqn_String16 Dqn_Win_String8ToString16(Dqn_Arena *arena, Dqn_String8 src); -DQN_API int Dqn_Win_String8ToString16Buffer(Dqn_String16 src, char *dest, Dqn_usize dest_size); +DQN_API int Dqn_Win_String8ToString16Buffer(Dqn_String16 src, char *dest, int dest_size); DQN_API Dqn_String8 Dqn_Win_String16ToString8(Dqn_Arena *arena, Dqn_String16 src); -DQN_API int Dqn_Win_String16ToString8Buffer(Dqn_String16 src, char *dest, Dqn_usize dest_size); +DQN_API int Dqn_Win_String16ToString8Buffer(Dqn_String16 src, char *dest, int dest_size); // NOTE: Path navigation =========================================================================== // NOTE: API ======================================================================================= diff --git a/dqn_strings.cpp b/dqn_strings.cpp index 7974e85..bde70b0 100644 --- a/dqn_strings.cpp +++ b/dqn_strings.cpp @@ -720,13 +720,13 @@ DQN_API char Dqn_Char_ToHex(char ch) { char result = DQN_CAST(char)-1; if (ch < 16) - result = DQN_HEX_LUT[ch]; + result = DQN_HEX_LUT[DQN_CAST(uint8_t)ch]; return result; } DQN_API char Dqn_Char_ToHexUnchecked(char ch) { - char result = DQN_HEX_LUT[ch]; + char result = DQN_HEX_LUT[DQN_CAST(uint8_t)ch]; return result; }