Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!wjh12!harvard!seismo!brl-tgr!ron From: ron@brl-tgr.ARPA (Ron Natalie ) Newsgroups: net.lang.c Subject: Re: Quoting C names Message-ID: <5817@brl-tgr.ARPA> Date: Thu, 15-Nov-84 20:46:30 EST Article-I.D.: brl-tgr.5817 Posted: Thu Nov 15 20:46:30 1984 Date-Received: Sat, 17-Nov-84 04:39:48 EST References: <1793@sun.uucp> Distribution: net Organization: Ballistic Research Lab Lines: 31 > > 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