help with a macro

Doug Gwyn gwyn at smoke.brl.mil
Sat May 11 13:42:13 AEST 1991


In article <595 at afc-tci.UUCP> joubert at afc-tci.UUCP (Joubert Berger) writes:
>I want to define a macro, lets call it UNDERLINE that would take a string
>as a parameter.  This macro should add some characters in front and behind
>the string.  Is this possible?
>I want to be able to say:
>	fprintf(f, "%s\n", UNDERLINE("test"));
>and it replaces the the "test" with the newly created string.
>Am I asking to much of the preprocessor?

Since you want to do this with the preprocessor, we may assume that
you want to do this only for STRING LITERAL arguments to the UNDERLINE()
macro.  In ANSI C, it is trivial:
	#define UNDERLINE(s) "\033[4m" s "\033[0m"
for example.  In older C implementations, it is unlikely that you will
be able to perform this operation via preprocessing.



More information about the Comp.lang.c mailing list