Re: Evaluating arithmetic expressions with macros (eval)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear all,

Apologies for my so late response, when Nick's one came in so promptly
and has been so useful.

Nick Bowler (2023/10/04 16:29 -0400):
> Hi,
>
> On 2023-10-04, Sébastien Hinderer <Sebastien.Hinderer@xxxxxxxx> wrote:
> > I find myself stuck with something which I assume is trivial. I define:
> >
> > m4_define([X], [9])
> > m4_define([Y], [3])
> >
> > And I would like to define Z as being the arithmetic sum of X and Y and
> > can seem to get it.
> >
> > I tried several variations of eval but had no success. I understand
> > that all the macros need to be expanded before eval is called but I
> > don't understand how to do it.
>
> The short answer for your specific example is to simply not quote the
> arguments:
>
>     m4_define([Z], m4_eval(X + Y))

Aht alone was useful. It made me realise that I was using eval, rather
than m4_eval. I assume this is why it didn't work as expected.

However, eval *is* documented in section 12.2 Evaluating integer
expressions of the m4 info manual.

Best wishes,

Sébastien.




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux