From 6039a51a243217b6e15c4f132487fe9684a8b0e4 Mon Sep 17 00:00:00 2001 From: momoyon Date: Tue, 20 May 2025 19:38:24 +0500 Subject: [PATCH] [commonlib.h] ASSERT() calls to DebugBreak() on MSVC. --- commonlib.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/commonlib.h b/commonlib.h index 9b3e4d7..2a14777 100644 --- a/commonlib.h +++ b/commonlib.h @@ -10,6 +10,14 @@ #include #include +#if defined(_WIN32) +// NOTE: Don't include unwanted files to speed up compilation +#define WIN32_LEAN_AND_MEAN +#define NOCOMM +#include +#undef C_ASSERT // Bruh +#endif + // Remove Prefix #ifdef COMMONLIB_REMOVE_PREFIX #define ASSERT C_ASSERT @@ -115,12 +123,21 @@ typedef const wchar* wstr; // Macros +#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) +#define C_ASSERT(condition, msg) do {\ + if (!(condition)) {\ + fprintf(stderr, "%s:%d:0 [ASSERTION FAILED] %s: %s", __FILE__, __LINE__, #condition, msg);\ + DebugBreak();\ + }\ + } while (0) +#else #define C_ASSERT(condition, msg) do {\ if (!(condition)) {\ fprintf(stderr, "%s:%d:0 [ASSERTION FAILED] %s: %s", __FILE__, __LINE__, #condition, msg);\ exit(1);\ }\ } while (0) +#endif // defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) #define C_ARRAY_LEN(arr) (sizeof(arr) / sizeof(arr[0])) @@ -732,7 +749,7 @@ c_String_view c_sv_get_part(c_String_view sv, int from, int to) { from = clampi(from, 0, sv.count); to = clampi(to, from, sv.count); - String_view range = { + c_String_view range = { .data = (char*)(sv.data + from), .count = (size_t)(to - from), }; -- 2.39.5