brad@sun.uucp (Brad Taylor) (11/14/84)
Is there any easy way to quote a C name?
Here is an example where it might be used:
#define FUNCNAME foo
void FUNCNAME()
{
static char *myself = QUOTE(FUNCNAME);
printf("(I'm in %s)",myself);
}
Note that only FUNCNAME need be changed in order to change the name of
the function.
-brad
ron@brl-tgr.ARPA (Ron Natalie <ron>) (11/16/84)
> > Is there any easy way to quote a C name? > Here is an example where it might be used: > > #define FUNCNAME foo > > void FUNCNAME() > { > static char *myself = QUOTE(FUNCNAME); > > printf("(I'm in %s)",myself); > } > > Note that only FUNCNAME need be changed in order to change the name of > the function. > > -brad > > You will note that do to an ambiguity in the C book, most of the popular C compilers will allow you to do this easily by the following: #define QUOTE(x) "x" When we typed all the C puzzles in to verify a compiler for the IBM 370 we found the compiler interpreted the statement in the C book the other way and wouldn't substitute the x. The above macro will work on the AT&T C preprocessor and hence all AT&T compilers as well as BSD. -Ron