>>>>> "Ed" == Ed Smith-Rowland <[email protected]> writes:
Ed> I have a situation where I would like to detect if a string is a
Ed> currently defined macro.
Ed> Something like a
Ed> bool cpp_is_macro(const unsigned char *);
Ed> would be great.
Ed> Or perhaps I could construct something from the string and test that.
Ed> If something like this doesn't exist does anyone have some pointers on
Ed> how to make one for libcpp.
Call ht_lookup and convert to a cpp hash node, e.g., from grepping:
return CPP_HASHNODE (ht_lookup (pfile->hash_table,
buf, bufp - buf, HT_ALLOC));
Then see if the node's 'type' field is NT_MACRO.
I think that should work.
See directives.c:do_ifdef for some bits.
E.g., you may consider marking the macro as "used".
Tom