]> www.git.momoyon.org Git - commonlib.git/commitdiff
[commonlib.h] ASSERT() calls to DebugBreak() on MSVC.
authormomoyon <momoyon@momoyon.org>
Tue, 20 May 2025 14:38:24 +0000 (19:38 +0500)
committermomoyon <momoyon@momoyon.org>
Tue, 20 May 2025 14:38:24 +0000 (19:38 +0500)
commonlib.h

index 9b3e4d7aeeecfa9f81ee1f2fd5678b22f8496c99..2a1477777235a48217e4a767686056c8d25eaa4e 100644 (file)
 #include <assert.h>\r
 #include <limits.h>\r
 \r
+#if defined(_WIN32)\r
+// NOTE: Don't include unwanted files to speed up compilation\r
+#define WIN32_LEAN_AND_MEAN\r
+#define NOCOMM\r
+#include <windows.h>\r
+#undef C_ASSERT // Bruh\r
+#endif\r
+\r
 // Remove Prefix\r
 #ifdef COMMONLIB_REMOVE_PREFIX\r
 #define ASSERT C_ASSERT\r
@@ -115,12 +123,21 @@ typedef const wchar* wstr;
 \r
 \r
 // Macros\r
+#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)\r
+#define C_ASSERT(condition, msg) do {\\r
+                if (!(condition)) {\\r
+                        fprintf(stderr, "%s:%d:0 [ASSERTION FAILED] %s: %s", __FILE__, __LINE__, #condition, msg);\\r
+                        DebugBreak();\\r
+                }\\r
+        } while (0)\r
+#else\r
 #define C_ASSERT(condition, msg) do {\\r
                 if (!(condition)) {\\r
                         fprintf(stderr, "%s:%d:0 [ASSERTION FAILED] %s: %s", __FILE__, __LINE__, #condition, msg);\\r
                         exit(1);\\r
                 }\\r
         } while (0)\r
+#endif // defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)\r
 \r
 #define C_ARRAY_LEN(arr) (sizeof(arr) / sizeof(arr[0]))\r
 \r
@@ -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);\r
     to   = clampi(to, from, sv.count);\r
 \r
-    String_view range = {\r
+    c_String_view range = {\r
         .data = (char*)(sv.data + from),\r
         .count = (size_t)(to - from),\r
     };\r