Maintaining global state with m4 macros
Paolo Amoroso <[email protected]> Thu, 2 Dec 2021 15:11:59 +0100
| Newsgroups | gmane.comp.gnu.m4.general |
|---|---|
| Message-ID | <CAGi1hzv1bxF5K85AQ0v=632PeEZ3MwHZKqNm9R=fRDKd364KEw@mail.gmail.com> |
Is it possible to create an m4 macro expanding to the next integer of
a global counter each time it's called?
In other words, assuming the counter has an initial value (e.g. 0),
these calls to such a nextcount macro:
First call: nextcount
Second call: nextcount
Third call: nextcount
should generate the following output:
First call: 1
Second call: 2
Third call: 3
I'm stumped as I'm not sure updating the global state of a counter is
even possible with m4. Is there any way?
Thanks,
Paolo