From: | |
Date: | 18 Feb 2001 at 01:05:06 |
Subject: | Re: "#define" for code |
Hi Andrew,
>From: Andrew Crowe <andrewcrowe@enterprise.net>
>#define code[a,b,c]{a=b*c+a}
>
>so that if you had the line:
>
>code[var1,var2,6]
>
>the compiler would convert that to
>
>var1=var2*6+var1
>
>before compiling (thus being faster thensubroutines).
>
>The only problem is I don't know the syntax for the define, and that
>example there didn't work.
You need to use curly brackets instead of square ones:
#define code(a,b,c) (b*c+a)
The "return" value of this would be the result of the expression, so to
assign it to 'a', you could call it like this:
int x,y,z;
x=code(x,y,z);
If you're interested in speed you could also use an inline function:
inline int code(int a, int b, int c)
{
return b*c+a;
}
This basically has the same effect as the macro, the code is inserted at
every point it is called, rather than a function call to it.
Thanks, Andrew
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
------------------------ Yahoo! Groups Sponsor ---------------------~-~>
eGroups is now Yahoo! Groups
Click here for more details
http://click.egroups.com/1/11231/0/_/451227/_/982454708/
---------------------------------------------------------------------_->