Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > Re: defining ma...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 1093 of 1183
Post > Topic >>

Re: defining macro parameters

by "Chris Thomasson" <cristom@[EMAIL PROTECTED] > May 15, 2008 at 11:00 AM

"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.
 




 4 Posts in Topic:
defining macro parameters
"Paul" <-@[E  2008-05-05 16:01:48 
Re: defining macro parameters
Andre Poenitz <poenitz  2008-05-09 17:33:21 
Re: defining macro parameters
sheleztt <sheleztt@[EM  2008-05-13 01:06:24 
Re: defining macro parameters
"Chris Thomasson&quo  2008-05-15 11:00:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 12:37:54 CST 2008.