Skip to content

Commit 19a991c

Browse files
committed
Basic: Handle missing __FILE_NAME__ on Windows
1 parent b366ae2 commit 19a991c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/swift/Basic/Assertions.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,27 @@
4141
// that are more expensive than you think. You can switch those to
4242
// `CONDITIONAL_ASSERT` or `DEBUG_ASSERT` as needed.
4343

44+
// Visual Studio doesn't have __FILE_NAME__
45+
#ifdef __FILE_NAME__
46+
4447
#define ASSERT(expr) \
4548
do { \
4649
if (ASSERT_UNLIKELY(!(expr))) { \
4750
ASSERT_failure(#expr, __FILE_NAME__, __LINE__, __func__); \
4851
} \
4952
} while (0)
5053

54+
#else
55+
56+
#define ASSERT(expr) \
57+
do { \
58+
if (ASSERT_UNLIKELY(!(expr))) { \
59+
ASSERT_failure(#expr, __FILE__, __LINE__, __func__); \
60+
} \
61+
} while (0)
62+
63+
#endif
64+
5165
// Function that reports the actual failure when it occurs.
5266
void ASSERT_failure(const char *expr, const char *file, int line, const char *func);
5367

0 commit comments

Comments
 (0)