From 24e7e0418fad27844b2d690c58d71b3b4bf5ddc7 Mon Sep 17 00:00:00 2001 From: Gwendolyn Date: Mon, 3 Jan 2022 15:20:44 +0100 Subject: [PATCH] use `__typeof__` instead of `typeof` and `__func__` instead of `__ASSERT_FUNC` for compatibility with other compilers and standard libraries (__ASSERT_FUNC seems to be a cygwin thing) --- xassert.h | 2 +- xtest.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xassert.h b/xassert.h index 6ce5193..0fb532d 100644 --- a/xassert.h +++ b/xassert.h @@ -13,6 +13,6 @@ void xtest_internal_assert(const char* file, int line, const char* func, const c #undef assert #define assert(__e) ((__e) ? (void)0 : xtest_internal_assert(__FILE__, __LINE__, \ - __ASSERT_FUNC, #__e)) + __func__, #__e)) #endif //defined(XTEST) && !defined(XTEST_XTEST_H) diff --git a/xtest.h b/xtest.h index df3f41c..d7cd7e8 100644 --- a/xtest.h +++ b/xtest.h @@ -104,7 +104,7 @@ int xtest_complete(); #define force_types_equal(a, b) (void) _Generic(a, \ - typeof(b): (void*)0 \ + __typeof__(b): (void*)0 \ ) @@ -112,8 +112,8 @@ int xtest_complete(); force_types_equal(expected, actual); \ int _xtest_res = (expr); \ if (!(_xtest_res)) { \ - typeof(actual) _xtest_a = actual; \ - typeof(expected) _xtest_e = expected; \ + __typeof__(actual) _xtest_a = actual; \ + __typeof__(expected) _xtest_e = expected; \ enum xtest_type _xtest_type = xtest_get_type(actual); \ xtest_fail_assert(s, __FILE__, __LINE__, &_xtest_e, &_xtest_a, invert, _xtest_type); \ } \