[lug] Weird 'C' preprocessor behavior

Alan Robertson alanr at unix.sh
Tue May 22 18:32:05 MDT 2001


Tom Tromey wrote:
> 
> Alan> Does anyone know how to get 'C' to give me the effect I want?
> 
> Add another layer of macro expansion.
> 
>     #define MODULE foo
> 
>     #define EXPORT2(module, function) module##__LTX__##function
>     #define X2(a,b) EXPORT2(a,b)
>     #define EXPORT(function) X2( MODULE, function)
>     #define TEST(function) printf("%s %s", MODULE, function)
> 
>     EXPORT(main)
> 
> Someone more language-lawyerly than I would have to tell you why.
> Or you could search the gcc list archives.  This comes up often enough
> that I remembered the solution.

Thanks Tom!

I suspect you know *exactly* why I wanted to do this too ;-) [libtool
dynamic loadable modules]

	-- Alan Robertson
	   alanr at unix.sh



More information about the LUG mailing list