"Paul" <-@[EMAIL PROTECTED]
> wrote in message
news:clcm-20080505-0018@[EMAIL PROTECTED]
>I would like to define a list of parameters, and then pass them to a
macro.
> However, the compiler (gcc) only sees one parameter, rather than
expanding
> the definition.
> Could anyone suggest a way of making this work (using the preprocessor)?
>
> #define MyList 1,2,3,4
>
> #define Sum(a,b,c,d) a+b+c+d
>
> x = Sum(MyList);
_____________________________________________________________
#include <stdio.h>
#define MyList() 1,2,3,4
#define Sum(a,b,c,d) a+b+c+d
#define FUNCALL_X(mfp, t) (mfp(t))
#define FUNCALL(mfp, t) FUNCALL_X(mfp, t())
int main() {
printf("%d\n", (int)FUNCALL(Sum, MyList));
getchar();
return 0;
}
_____________________________________________________________
Does that work for you?
--
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
-- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line. Sorry.


|