[net.unix-wizards] cpp quoting tricks??

greg (10/20/82)

One thing that DOES work is:

#define NAME(a) "/dev/a"

then NAME(mt0) will expand (believe it or not) to "/dev/mt0".
I wish I could claim it was original, but I found it hidden
in some code from UCB once......

wan.gatech@Udel-Relay@sri-unix (10/25/82)

From:     Peter N Wan <wan.gatech@Udel-Relay>
Date:     21 Oct 82 12:10:32-EDT (Thu)
Greg,
	How about using 'sprintf' to build your string?  For instance,
you can do :

		# define TAPE 1
		.
		.
			char dev_template[] = "/dev/mt%-02d";
			char device_name[128];
			int  dev_number;
		.
		.
			dev_number = TAPE;
			sprintf (device_name, dev_template, dev_number);

'device_name' should contain the device name, e.g. "/dev/mt1".  Forgive
me if there are a few things wrong in the above example; but I think that
you get the idea.  It uses up more storage and requires a little run-time
time, but it does give you the flexibility that I think that you were
looking for.
						Peter Wan
					      Georgia Tech