How to accumulate tokens in #define'd ident ?

Jonathan Wakely jwakely.gcc@gmail.com
Tue May 27 09:30:00 GMT 2014


On 27 May 2014 06:11, phi gcc wrote:
> Hi All,
>
> I have a beginner question.
> I have an ident that I #define this is a comma separated list of other
> ident, and I'd like to augment this list, i.e basically something like
>
> #define L a
> #define T L
> #undef L
> #define L T,b
>
> I have a growing list of ident (here a,b) I'd like to grow this as
> include files to end up with a,b,c,d at some point this is given to a
> va_args function like f(L)
>
> Indeed I know that the above #define/#undef will not make it, yet I
> tried a lot of combo with ## in macro like
>
> #define A(l,x) l##,##x
> #define l a
> #define t A(l,b)
> #undef l
> #define l t
>
> But nothing works.

You could have a look at how Boost.Preprocessor does this kind of
thing, but using the preprocessor like this leads to madness.



More information about the Gcc-help mailing list