Skip to content

Commit 61047f9

Browse files
committed
Minor tweaks to assert
1 parent 9b9b919 commit 61047f9

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

extlib.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ static inline int strcmp(const char *l, const char *r) {
260260
#ifndef NDEBUG
261261

262262
#ifndef EXTLIB_NO_STD
263+
263264
#define EXT_ASSERT(cond, msg) \
264265
((cond) ? ((void)0) \
265266
: (fprintf(stderr, "%s:%d: error: %s failed: %s\n", __FILE__, __LINE__, #cond, msg), \
@@ -269,14 +270,8 @@ static inline int strcmp(const char *l, const char *r) {
269270
(fprintf(stderr, "%s:%d: error: reached unreachable code\n", __FILE__, __LINE__), abort())
270271

271272
#elif defined(EXTLIB_WASM) && defined(__clang__)
272-
273-
#define EXT_ASSERT(cond, msg) \
274-
do { \
275-
if(!(cond)) __builtin_trap(); \
276-
} while(0)
277-
278-
#define EXT_UNREACHABLE() __builtin_trap()
279-
273+
#define EXT_ASSERT(cond, msg) ((cond) ? ((void)0) : __builtin_trap())
274+
#define EXT_UNREACHABLE() __builtin_trap()
280275
#else
281276
#define EXT_ASSERT(cond, msg) assert((cond) && msg)
282277
#define EXT_UNREACHABLE() assert(false && "reached unreachable code")

0 commit comments

Comments
 (0)