File macro_helpers.h

Parent directory (include/mola_yaml)

C preprocessor helpers for variadic macro dispatch.

Definition (include/mola_yaml/macro_helpers.h)

Detailed Description

Jose Luis Blanco Claraco

Jan 11, 2019

Provides the VFUNC(func, ...) macro, which dispatches to a suffixed overload of func based on the number of variadic arguments supplied.

Example

Given two “overloads”: #defineMY_MACRO2(a,b)… #defineMY_MACRO3(a,b,c)…

A single entry-point can be declared as: #defineMY_MACRO(…)VFUNC(MY_MACRO,__VA_ARGS__) MY_MACRO(x, y) expands to MY_MACRO2(x, y) and MY_MACRO(x, y, z) expands to MY_MACRO3(x, y, z).

Up to 10 arguments are supported.

Adapted from https://stackoverflow.com/a/26408195/1631514

Included By

Defines