[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc
Subject: Re: passing #define-d values to #define-d macros
From: Nathan Froyd <froydnj () codesourcery ! com>
Date: 2010-09-27 1:25:34
Message-ID: 20100927012533.GS16898 () codesourcery ! com
[Download RAW message or body]
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-help@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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic