example 1:
file: classes.inl
DECLARE_ATOM_CLASS( AC_STATIC, static )
DECLARE_ATOM_CLASS( AC_DYNAMIC, dynamic )
DECLARE_ATOM_CLASS( AC_MULTISTATE, multistate )
and now use it:
enum atom_class_e
{
AC_FIRST_LIST = 0,
#define DECLARE_ATOM_CLASS( e, a ) e,
#include "classes.inl"
#undef DECLARE_ATOM_CLASS
ATOM_CLASSES_COUNT,
AC_UNDEFINED,
};
atom_c::atom_definition_s atom_c::g_classes[ ATOM_CLASSES_COUNT ] =
{
#define DECLARE_ATOM_CLASS( e, a ) { #a, atom_##a##_c::instance },
#include "classes.inl"
#undef DECLARE_ATOM_CLASS
};
example 2:
#define LOGICPARAMS \ LPRM( CUSTOMVAR1, prm_word ) \ LPRM( CUSTOMVAR2, prm_word ) \ LPRM( MTYPE, prm_mtype ) \ LPRM( LOCTYPE, prm_loctype ) \ LPRM( SURFTYPE, prm_surftype )
and now use it:
// types
#define LPRM(x, y) typedef y::TYPE typeof_##x;
LOGICPARAMS
#undef LPRM
// enum : LP_CUSTOMVAR1, LP_CUSTOMVAR2 ... LP_max
#define LPRM(x, y) LP_##x,
enum lp_e { LOGICPARAMS LP_max };
#undef LPRM
// sizeof : LPSZ_CUSTOMVAR1, LPSZ_CUSTOMVAR2 ...
#define LPRM(x, y) LPSZ_##x = sizeof(y::TYPE),
enum lpsz_e { LOGICPARAMS };
#undef LPRM