CFG_START()
CFG_ADD(int, FOO, /* some more stuff */)
CFG_ADD(short, BAR, /* some more stuff */)
CFG_ADD(float, BAZ, /* some more stuff */)
CFG_END()
####
/* simplified */
MetaData_t metadata = {
#define CFG_ADD(TYPE,NAME,STUFF) { .compFunc = compare_ ## TYPE; /* and some more stuff */ }
#include "configfile.h"
#undef CFG_ADD
}
####
#define CFG_ADD(TYPE,NAME,STUFF) \
#ifndef USING_ ## TYPE /* does not work */ \
#define USING_ ## TYPE /* does not work */ \
#endif
#include "configfile.h"
#undef CFG_ADD
/* and later: */
#ifdef USING_int
static int compare_int(const void * a, const void * b);
#endif
#ifdef USING_double
static int compare_double(const void * a, const void * b);
#endif
/* further down */
#ifdef USING_int
static int compare_int(const void * a, const void * b)
{
/* ... */
}
#endif
#ifdef USING_double
static int compare_double(const void * a, const void * b)
{
/* ... */
}
#endif