From 45ae14cadc2e867a6916db5aec9ebbd2716cc007 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Thu, 26 Jan 2023 18:55:31 +0000 Subject: [PATCH] core: Fix unused variable warning of no-op NS_ASSERT macros --- src/core/model/assert.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/model/assert.h b/src/core/model/assert.h index 104a9e97c..b7132e85b 100644 --- a/src/core/model/assert.h +++ b/src/core/model/assert.h @@ -95,16 +95,20 @@ #else /* NS3_ASSERT_ENABLE */ +// NOTE: The no-op macros are not inserted into the final code. +// However, the use of sizeof() allows the compiler to silently check if the condition is +// syntactically valid. + #define NS_ASSERT(condition) \ do \ { \ - sizeof(condition); \ + (void)sizeof(condition); \ } while (false) #define NS_ASSERT_MSG(condition, message) \ do \ { \ - sizeof(condition); \ + (void)sizeof(condition); \ } while (false) #endif /* NS3_ASSERT_ENABLE */