On Sun, Sep 26, 2010 at 06:09:34PM -0700, ir_idjit wrote:
> i can seem to get this to work:
> 
> #define PREFIX "____p_"
> #define HIGHER_INTERFACE(id) ____LOWER_INTERFACE(PREFIX, id)
> 
> #define ____LOWER_INTERFACE(prefix, id) struct prefix##id \
> { \
> int i; \
> }
> 
> int main(void)
> {
> HIGHER_INTERFACE(0);
> 
> /* test if struct declaration went well: */
> struct ____p_0 var;
> return 0;
> }

This question is not appropriate for the mailing list gcc@gcc.gnu.org,
which is for gcc development.  It would be appropriate for a forum about
using the C language, such as the newsgroup comp.lang.c or
gcc-h...@gcc.gnu.org.  Please take any followups to gcc-help.  Thanks.

Your problem can be solved by using another layer of indirection and
making PREFIX to not be a string:

#define PREFIX ____p_
#define HIGHER_INTERFACE(id) L2(PREFIX, id)

#define L2(prefix,id) ____LOWER_INTERFACE(prefix,id)
#define ____LOWER_INTERFACE(prefix, id) struct prefix##id \
{ \
int i; \
}

int main(void)
{
HIGHER_INTERFACE(0);

/* test if struct declaration went well: */
struct ____p_0 var;
return 0;
}

-Nathan

Reply via email to