From: Willy Tarreau Date: Wed, 1 Jul 2026 12:39:08 +0000 (+0200) Subject: MINOR: compiler: add a macro to ignore all arguments X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/static/gitweb.js?a=commitdiff_plain;h=7fc3a52aaf606ff2e55279216676f0419e11d429;p=haproxy.git 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. --- 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 */