[comp.lang.c] need cpp macros to concatenate names

bret@hi.UUCP (Bret K. Thaeler) (05/06/87)

> #define prefix my
> 
> #define concat(x,y) x\
> y
> 
> main()
> {
> 	long *concat(prefix,file);
> }
> 

This is our attempt. This was done on a Sun running 3.3.

#define pre()my
#define prefix pre()
#define concat(x,y)x//**/**/y

main()
{
	long *concat(prefix,file);
}

----------------- producing -----------------
main()
{
	long *myfile;
}

=============================================


Now for the hard one.... What if you want BOTH of the concat() args
to be #define's??? 

#define  prefix my
#define  post()file
#define  postfix post()
#define concat(x,y)x//**/**/y

main()
{
	long *concat(prefix,postfix);
}

----------------- producing -----------------

main()
{
	long *myfile;
}

=============================================

Brought to you by the minds of ... 
	--Bret

Who said hackers were no good bums?
	--Josh

Who needs m4?
	--Kurt


-- 
--------------------------------------------------------------------------------
Bret K. Thaeler		     ARPA: thaeler@hc.dspo.gov  |          /// Amiga
College of Enginering, UNM   UUCP: hc!thaeler           |         /// user
Professional Student                                    |   \\\  ///
Of: (505) 277-1611    Ho: (505) 277-4497		|    \\\///  And dam
I instinctively used the Vulcan death grip.             |     \///  proud,
 ofak