Basic: Handle missing __FILE_NAME__ on Windows

This commit is contained in:
Slava Pestov
2024-06-22 08:52:37 -04:00
parent b366ae238c
commit 19a991c530

View File

@@ -41,6 +41,9 @@
// that are more expensive than you think. You can switch those to
// `CONDITIONAL_ASSERT` or `DEBUG_ASSERT` as needed.
// Visual Studio doesn't have __FILE_NAME__
#ifdef __FILE_NAME__
#define ASSERT(expr) \
do { \
if (ASSERT_UNLIKELY(!(expr))) { \
@@ -48,6 +51,17 @@
} \
} while (0)
#else
#define ASSERT(expr) \
do { \
if (ASSERT_UNLIKELY(!(expr))) { \
ASSERT_failure(#expr, __FILE__, __LINE__, __func__); \
} \
} while (0)
#endif
// Function that reports the actual failure when it occurs.
void ASSERT_failure(const char *expr, const char *file, int line, const char *func);