Add NXT_UNUSED to silence unused warnings

This commit is contained in:
Corentin Wallez
2018-06-12 10:28:52 -04:00
committed by Corentin Wallez
parent 5ab96e0d40
commit 82565b340f
5 changed files with 10 additions and 6 deletions

View File

@@ -55,7 +55,7 @@
# else
# define NXT_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
do { \
(void)sizeof(condition); \
NXT_UNUSED(sizeof(condition)); \
} while (NXT_ASSERT_LOOP_CONDITION)
# endif
#endif

View File

@@ -22,6 +22,7 @@
// - NXT_NO_DISCARD: An attribute that is C++17 [[nodiscard]] where available
// - NXT_(UN)?LIKELY(EXPR): Where available, hints the compiler that the expression will be true
// (resp. false) to help it generate code that leads to better branch prediction.
// - NXT_UNUSED(EXPR): Prevents unused variable/expression warnings on EXPR.
// Clang and GCC
#if defined(__GNUC__)
@@ -72,6 +73,9 @@ extern void __cdecl __debugbreak(void);
# error "Unsupported compiler"
#endif
// It seems that (void) EXPR works on all compilers to silence the unused variable warning.
#define NXT_UNUSED(EXPR) (void)EXPR
// Add noop replacements for macros for features that aren't supported by the compiler.
#if !defined(NXT_LIKELY)
# define NXT_LIKELY(X) X