From 795914e50c96cc1d62cdd8c28562b0e4689a1949 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 12 Dec 2024 18:31:24 +0100 Subject: [PATCH] [winpr,assert] always compile in assert helper --- winpr/include/winpr/assert-api.h | 18 ++++++++++++------ winpr/libwinpr/crt/assert.c | 2 -- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/winpr/include/winpr/assert-api.h b/winpr/include/winpr/assert-api.h index b003174d5..b1e32217e 100644 --- a/winpr/include/winpr/assert-api.h +++ b/winpr/include/winpr/assert-api.h @@ -34,22 +34,28 @@ winpr_int_assert(#cond, (file), (fkt), (line)); \ } while (0) +#else +#define winpr_internal_assert(cond, file, fkt, line) assert(cond) +#endif + #ifdef __cplusplus extern "C" { #endif - extern WINPR_NORETURN(void winpr_int_assert(const char* condstr, const char* file, - const char* fkt, size_t line)); + /* this function meant only to be used by WINPR_ASSERT + * it needs to be exported as our assert implementation calls this for debug logging. + * + * also export when WITH_VERBOSE_WINPR_ASSERT is disabled as other software might compile with + * it enabled + */ + WINPR_API WINPR_NORETURN(void winpr_int_assert(const char* condstr, const char* file, + const char* fkt, size_t line)); #ifdef __cplusplus } #endif -#else -#define winpr_internal_assert(cond, file, fkt, line) assert(cond) -#endif - #define WINPR_ASSERT_AT(cond, file, fkt, line) \ do \ { \ diff --git a/winpr/libwinpr/crt/assert.c b/winpr/libwinpr/crt/assert.c index cd66f531b..bfc468432 100644 --- a/winpr/libwinpr/crt/assert.c +++ b/winpr/libwinpr/crt/assert.c @@ -22,7 +22,6 @@ #include #include -#if defined(WITH_VERBOSE_WINPR_ASSERT) && (WITH_VERBOSE_WINPR_ASSERT != 0) void winpr_int_assert(const char* condstr, const char* file, const char* fkt, size_t line) { wLog* _log_cached_ptr = WLog_Get("com.freerdp.winpr.assert"); @@ -30,4 +29,3 @@ void winpr_int_assert(const char* condstr, const char* file, const char* fkt, si winpr_log_backtrace_ex(_log_cached_ptr, WLOG_FATAL, 20); abort(); } -#endif