apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: Creative solution to a lack of recursive #define's?
Date Fri, 25 Apr 2003 20:53:09 GMT
At 03:04 PM 4/25/2003, Jessie Oberreuter wrote:

>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;
>     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.

I'm familiar with it.  The way we provide hooks, the user is responsible
for using two declaration macros, one for the prototype (e.g. in their .h)
and one for the implementation (e.g. in a .c)...

The one I'm most interested in is the declarator, study just this bit below;

#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); \

APR_DECLARE_EXTERNAL_HOOK(foo,FOO,dee_t*,twiddle,(dee_t *dum))

Gives you a function declaration;
FOO_DECLARE(dee_t *) foo_hook_twiddle(foo_HOOK_twiddle_t *pf,
                                      const char * const *aszPre,
                                      const char * const *aszSucc, int nOrder,
                                      const char * szFnName);

What I really want is for the fifth arg above, szFnName, to actually be
the stringized version of the pf callback... 

#define foo_hook_twiddle(pf, aszPre, aszSucc, nOrder) \
        (foo_hook_twiddle)(pf, aszPre, aszSucc, nOrder, #pf)

However, using this declarator wrapper, it seems to be impossible to
provide this redefinition of foo_hook_twiddle without forcing the user
to do so themselves.

My question is how is it possible for our declarator macro to provide
this same functionallity, transparently, to any author who uses the

Your solution works for that last define I illustrated above.  But how is
it possible to provide this in terms of the declaration macro we use?


View raw message