Hygiene of #define DIR "/usr/lib/news (CLEAN UP)

Jan Steinman jans at mako.UUCP
Sat Feb 16 03:52:18 AEST 1985


In article <5053 at elsie.UUCP> ado at elsie.UUCP (Arthur David Olson) writes:
>... a thought-provoking way of doing string catenation...
>
>	#define DIR "/usr/lib/news
>
>and used these defines in lines such as
>
>	system(DIR/batch");
>
Most pre-processors work with whitespace delimited tokens, so the above will
not always work.  However, tokens are not allowed to contain embedded
comments, so this is a more portable way to do the trick:

	system(DIR/**//batch");

I use this technique regularly to produce unique labels for assembly macro
expansion:

	#define MY_MACRO(garbage_in)		\
		.globl my_routine/**/garbage_in	\
	my_routine/**/garbage_in:		\
		...(assembly code)...		\
	/* end define MY_MACRO */
-- 
:::::: Jan Steinman		Box 1000, MS 61-161	(w)503/685-2843 ::::::
:::::: tektronix!tekecs!jans	Wilsonville, OR 97070	(h)503/657-7703 ::::::



More information about the Comp.lang.c mailing list