[comp.lang.c] C preprocessor definition for current function name.

daveh@marob.masa.com (Dave Hammond) (02/16/90)

Thanks to all those who responded to my query about a preprocessor
definition for the current function name.  As a general rule, this can
not be done since the preprocessor is typically not integrated with the
C parser and has no understanding of C syntax or expressions.

Karl Heuer offered the most reasonable solution, which is to manually
update a constant at the entry to each function, ie:

#undef FUNCTION
#define FUNCTION "main"
main(void)
{
...
}

#undef FUNCTION
#define FUNCTION "foo"
foo(void)
{
...
}


In retrospect, I should apologize for wasting bandwidth with this
question, since I am well aware that my machine's C preprocessor is not
integrated with the compiler.  Given a bit of thought before posting, I
would have answered my own question.

--
Dave Hammond
daveh@marob.masa.com
uunet!masa.com!marob!daveh