Here is a macro that defines a function (I deliberately simplified my macro) :
#define GET_VALUE_IMPL(func_name, value_type, get_func) \
static value_type func_name(const char *token, value_type def_value) \
{ \
value_type value; \
assert(token != NULL); \
value = get_func(token, def_value); \
return value; \
}
And then, I'm using this macro like this to define two functions, get_int
and get_string
:
GET_VALUE_IMPL(get_int, int, external_get_int);
GET_VALUE_IMPL(get_string, char*, external_get_str);
Here is my problem: for get_string
, I'd like to pass a function as a fourth parameter to GET_VALUE_IMPL
that would be called on value after the assignement value = get_func(token, def_value);
How could I do that with the preprocessor?