From 7fc3a52aaf606ff2e55279216676f0419e11d429 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 1 Jul 2026 14:39:08 +0200 Subject: [PATCH] MINOR: compiler: add a macro to ignore all arguments Regularly when disabling features (e.g. traces), some macros that would make use of some arguments end up not consuming them at all, making the compiler complain that "variable foo defined but not used". An elegant way to generically mark arguments as used is to pass them to a variadic function. However a first argument is needed. So we create a macro that passes (0, __VA_ARGS__) to an inline function that does nothing from its arguments, and that's done. --- include/haproxy/compiler.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/haproxy/compiler.h b/include/haproxy/compiler.h index 3f7f3bc8e..b74e636bb 100644 --- a/include/haproxy/compiler.h +++ b/include/haproxy/compiler.h @@ -591,4 +591,15 @@ # endif #endif +/* Eats all arguments ignoring their types and contents. This is useful + * to avoid "foo declared but not used" warnings. A first non-empty arg + * is required by the function, but it's inserted by the macro. + */ +#define __eat_all_args(...) ___eat_all_args(0, __VA_ARGS__) +static inline __attribute__((always_inline)) void ___eat_all_args(int ignore, ...) +{ + (void)ignore; +} + + #endif /* _HAPROXY_COMPILER_H */ -- 2.47.3