Topic: Function-like macros
Author: tinct@163.com (Tinct)
Date: Thu, 20 Sep 2001 16:50:41 GMT Raw View
davlet_panech@my-deja.com (Davlet Panech) wrote in message news:<86b42096.0109181203.65c44d6e@posting.google.com>...
> Hi,
>
> Is the following code legal?
>
> #define LPAREN (
> #define RPAREN )
> #define A(x) x
> A LPAREN int y RPAREN ;
>
> In other words, does the last line invoke macro A?
>
> Thanks,
> D.P.
>
> ---
I do not think so. The last line will be:
A ( int y ) ;
There is a space between 'A' and '(', so it will not be treated as a MACRO A().
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: davlet_panech@my-deja.com (Davlet Panech)
Date: Thu, 20 Sep 2001 21:05:09 GMT Raw View
tinct@163.com (Tinct) wrote in message news:<5450facb.0109191814.5aea776f@posting.google.com>...
> davlet_panech@my-deja.com (Davlet Panech) wrote in message news:<86b42096.0109181203.65c44d6e@posting.google.com>...
> > Hi,
> >
> > Is the following code legal?
> >
> > #define LPAREN (
> > #define RPAREN )
> > #define A(x) x
> > A LPAREN int y RPAREN ;
> >
> > In other words, does the last line invoke macro A?
> >
> > Thanks,
> > D.P.
> >
> > ---
>
> I do not think so. The last line will be:
> A ( int y ) ;
> There is a space between 'A' and '(', so it will not be treated as a MACRO A().
No, whitespace is significant only in macro definitions:
#define A(x) // one parameter
#define A (x) // no parameters
but not in macro invocations. My question is whether or not macros
LPAREN & RPAREN will be expanded before A is expanded. I think not,
but I just wanted to confirm that.
D.P.
>
> ---
> [ comp.std.c++ is moderated. To submit articles, try just posting with ]
> [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
> [ --- Please see the FAQ before posting. --- ]
> [ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: Attila Feher <Attila.Feher@lmf.ericsson.se>
Date: Fri, 21 Sep 2001 16:51:25 GMT Raw View
Davlet Panech wrote:
[SNIP]
> but not in macro invocations. My question is whether or not macros
> LPAREN & RPAREN will be expanded before A is expanded. I think not,
> but I just wanted to confirm that.
Not with SUN and I guess the way it works is sequential, so A will stay
A then you get ( and so on. I have tested by printing out the
preprocessed code.
Attila
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: davlet_panech@my-deja.com (Davlet Panech)
Date: Tue, 18 Sep 2001 20:09:57 GMT Raw View
Hi,
Is the following code legal?
#define LPAREN (
#define RPAREN )
#define A(x) x
A LPAREN int y RPAREN ;
In other words, does the last line invoke macro A?
Thanks,
D.P.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]