Re: Preprocessor possibilities
- From: "Robert Gamble" <rgamble99@xxxxxxxxx>
- Date: 13 Dec 2005 10:39:41 -0800
Christopher Benson-Manica wrote:
> Is it possible to write a macro (in unextended C89) such that
>
> TEST( int, (1,2,3) );
>
> expands to
>
> int array[]={ 1,2,3 };
>
> ? I strongly suspect that it is not, but I don't wish to overlook a
> solution if one exists.
No, there isn't. The closest thing you can do is something like the
following which is quite ugly:
#define TEST(x,y) x array[]={y}
#define SEP ,
TEST(int, 1 SEP 2 SEP 3);
and I am not positive that even this is valid in C89.
Robert Gamble
.
- Follow-Ups:
- Re: Preprocessor possibilities
- From: Christopher Benson-Manica
- Re: Preprocessor possibilities
- References:
- Preprocessor possibilities
- From: Christopher Benson-Manica
- Preprocessor possibilities
- Prev by Date: Re: Preprocessor possibilities
- Next by Date: Re: FIbonacci
- Previous by thread: Re: Preprocessor possibilities
- Next by thread: Re: Preprocessor possibilities
- Index(es):
Relevant Pages
|