I'm not actually following what you are working on, but this may help.
There is a "stringize" operator, the single hash, eg:
#define DEF(a) const char* a=#a;
DEF(ERROR_ARRAY_OVERRUN) =>
const char* ERROR_ARRAY_OVERRUN="ERROR_ARRAY_OVERRUN";
This is monumentally useful for building self-enumerating sets,
hooks, and other such toys that are capable of reporting or perfoming
lookups by their own names.
On Fri, 25 Apr 2003, William A. Rowe, Jr. wrote:
> I'm attempting to come up with some more clever tracing semantics.
> One thing I would like out of the user's foo_hook_method() invocation
> is the stringized 'name' of their hook entry point. Seems I hit a wall.
>
> Right now, apr_hooks uses the global 'apr_hook_debug_current'
> pointer to track which module is registering hooks. Mostly painless
> for the usual cases, since Apache sets up that pointer as it invokes
> a module's register_hooks() entry point. But if a hook is registered
> outside of that function, whoa boy.
>
> Anyways, since the recursive #defines below don't work, and we don't
> want the hook implementor to have to go through any 'extra' hoops,
> does anyone have some thoughts on the fragment below for stringizing
> the entry point 'pf's name?
>
> #define APR_IMPLEMENT_HOOK_TRACE_PROTO(ns,name) \
> #define ns##_hook_##name(pf, aszPre, aszSucc, nOrder) \
> (ns##_hook_##name)(pf, aszPre, aszSucc, nOrder, #pf)
>
> /** macro to declare the hook correctly */
> #define APR_DECLARE_EXTERNAL_HOOK(ns,link,ret,name,args) \
> typedef ret ns##_HOOK_##name##_t args; \
> link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf, \
> const char * const *aszPre, \
> const char * const *aszSucc, int nOrder\
> const char * szFnName); \
> link##_DECLARE(ret) ns##_run_##name args; \
> APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name); \
> APR_IMPLEMENT_HOOK_TRACE_PROTO(ns,name) \
> typedef struct ns##_LINK_##name##_t \
> { \
> ns##_HOOK_##name##_t *pFunc; \
> const char *szName; \
> const char * const *aszPredecessors; \
> const char * const *aszSuccessors; \
> int nOrder; \
> } ns##_LINK_##name##_t;
>
>
>