MINOR: tools: add new macro DEFZERO to provide a default zero argument

This is the equivalent of DEFNULL except that it sets a zero value instead
of a NULL for a missing argument.
This commit is contained in:
Willy Tarreau 2024-11-19 15:44:32 +01:00
parent c5052bad8a
commit e57581d76d
1 changed files with 6 additions and 0 deletions

View File

@ -51,6 +51,12 @@
* use in macros arguments.
*/
#define DEFNULL(...) _FIRST_ARG(NULL, ##__VA_ARGS__, NULL)
/* DEFZERO() returns either the argument as-is, or 0 if absent. This is for
* use in macros arguments.
*/
#define DEFZERO(...) _FIRST_ARG(NULL, ##__VA_ARGS__, 0)
#define _FIRST_ARG(a, b, ...) b
/* options flags for parse_line() */