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:
parent
c5052bad8a
commit
e57581d76d
|
@ -51,6 +51,12 @@
|
||||||
* use in macros arguments.
|
* use in macros arguments.
|
||||||
*/
|
*/
|
||||||
#define DEFNULL(...) _FIRST_ARG(NULL, ##__VA_ARGS__, NULL)
|
#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
|
#define _FIRST_ARG(a, b, ...) b
|
||||||
|
|
||||||
/* options flags for parse_line() */
|
/* options flags for parse_line() */
|
||||||
|
|
Loading…
Reference in New Issue