Related articles |
---|
[10 earlier articles] |
Re: Looking for volunteers for XL christophe@taodyne.com (Christophe de Dinechin) (2011-11-28) |
Re: Looking for volunteers for XL gah@ugcs.caltech.edu (glen herrmannsfeldt) (2011-11-29) |
Re: Looking for volunteers for XL jussi.santti@ard.fi (ardjussi) (2011-11-30) |
Re: Looking for volunteers for XL kaz@kylheku.com (Kaz Kylheku) (2011-12-01) |
Re: Looking for volunteers for XL kaz@kylheku.com (Kaz Kylheku) (2011-12-01) |
Re: Looking for volunteers for XL blog@rivadpm.com (Alex McDonald) (2011-12-01) |
Re: Looking for volunteers for XL jgk@panix.com (2011-12-13) |
Re: macros, was Looking for volunteers for XL kaz@kylheku.com (Kaz Kylheku) (2011-12-13) |
Re: macros, was Looking for volunteers for XL kaz@kylheku.com (Kaz Kylheku) (2011-12-14) |
Re: macros, was Looking for volunteers for XL jgk@panix.com (2011-12-15) |
Re: macros, was Looking for volunteers for XL kaz@kylheku.com (Kaz Kylheku) (2011-12-16) |
Re: Looking for volunteers for XL thomas.mertes@gmx.at (tm) (2012-01-03) |
From: | jgk@panix.com (Joe keane) |
Newsgroups: | comp.compilers |
Date: | Tue, 13 Dec 2011 00:08:53 +0000 (UTC) |
Organization: | Public Access Networks Corp. |
References: | 11-11-048 11-11-061 11-11-064 11-12-002 |
Keywords: | design, syntax,macros |
Posted-Date: | 12 Dec 2011 20:15:28 EST |
Kaz Kylheku <kaz@kylheku.com> wrote:
>For one thing, any syntactic unit that contains declarations cannot be
>an expression that returns a value. Macros that need to generate
>complex code that requires hidden variables automatically have a
>difficulty in returning a value in a function-call-like way, because
>only expressions do that.
That is valid, but it's not not-difficulty work-around-ed.
#2. Don't use function-like macros.
Make the result one of the parameters (unless it is really simple, then
some day in the future your 'really simple' macro is not so really
simple).
e.g.
#define GET_FORDO_BIT(FOP) \
...
int f(int x)
{
...
if (GETFORDO_BIT(fop))
{
...
}
...
}
versus
#define GET_FORDO_BIT(FOP, FOB) \
...
int f(int x)
{
...
GET_FORDO_BIT(fop, fob);
if (fob)
{
...
}
...
}
How hard is that?
Return to the
comp.compilers page.
Search the
comp.compilers archives again.