[lug] Weird 'C' preprocessor behavior

Tom Tromey tromey at redhat.com
Tue May 22 14:09:28 MDT 2001


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.

Tom



More information about the LUG mailing list