Testing if a function is defined in a module
Carlos Smith
carlos-smith at sympatico.ca
Tue Feb 20 20:33:40 PST 2007
"Kirk McDonald" <kirklin.mcdonald at gmail.com> wrote in
message news:erggra$lc1
: static if (is(typeof(&YYUSERINIT))) {
: // Do stuff with the function
: }
: However, I can't help but wonder what situation you're in
where you need
: to check this directly. I'm just guessing, here, but you'd
probably be
: better off using a version flag:
I am trying to add D support to flex. Without completly
rewriting it.
GNU programs use the preprocessor a lot, and in ways
not easy to translate to D.
Given a grammar, flex generate a C lexer for that grammar.
The user can define a macro YYUSERINIT. That macro will be
expanded if the test:
#ifdef YYUSERINIT
YYUSERINIT();
#endif
is satisfied. flex does not know, and does need to know
if YYUSERINIT is defined.
But, he [the user] may also not define it, and everything
will compile
ok.
Your first suggestion is exactly what i am looking for.
That can be also used to generate a default version for
a function, in the case the user does not define his own.
eg:
int yywrap( ) { return 1;}
Thanks a lot.
More information about the Digitalmars-d-learn
mailing list