Re: Macros
- From: "Harry" <gehariprasath@xxxxxxxxx>
- Date: 28 Nov 2006 03:01:44 -0800
Peter "Shaggy" Haywood wrote:
Groovy hepcat Walter Roberson was jivin' on Tue, 28 Nov 2006 07:57:39
+0000 (UTC) in comp.lang.c.
Re: Macros's a cool scene! Dig it!
In article <1164698162.284936.137360@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Harry <gehariprasath@xxxxxxxxx> wrote:
I have a piece of code as
# define prod(a,b)=a*b
main()
{
int x=2;
int y=3;
printf("%d",prod(x+2,y-10));
}
will the macro be evaluated as (2+2)*(3-10)=4* -7 =-28.
No, each dummy argument will be *textually* dropped into place exactly
as specified. Thus, your line would expand to
printf("%d",x+2*y-10);
No, it would expand to this:
printf("%d",=x+2*y-10);
which is a syntax error.
- don't use = in the macro definition
Exactly.
--
Dig the even newer still, yet more improved, sig!
http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
Sorry guys,that = is not present in the maro expansion.It was my
mistake & thanks for clearing the doubt.
.
- Follow-Ups:
- Re: Macros
- From: Keith Thompson
- Re: Macros
- References:
- Macros
- From: Harry
- Re: Macros
- From: Walter Roberson
- Re: Macros
- From: Peter "Shaggy" Haywood
- Macros
- Prev by Date: [OT] Re: Reading a string of unknown size
- Next by Date: Re: Most Interesting Bug Track Down
- Previous by thread: Re: Macros
- Next by thread: Re: Macros
- Index(es):
Relevant Pages
|
|