I would like to use m4
for doing some type-saving stuffs, so the loop will be definitely needed. When I read m4
doc, in chapter 6 there is 6.4
and 6.5
for iteration. But it looks like that foreach
is not a builtin macro (Composite?), how could I use it? In the example, they invoke m4
with -I examples
option, and include('foreach.m4')
, but this file seems not exist with error as:
cannot open `foreach.m4': No such file or directory
Any help is appreciated!
Li
You must use a full path as the argument to -I
(or a relative path, but you must specify the directory). Note that the examples directory is not always installed along with m4
(the m4-1.4.1 rpm distributed with RedHat does not include the examples directory.) The simplest thing to do would be to unpack an m4 tarball and use it. (eg, unpack the tarball in /tmp
and run m4 -I/tmp/m4-1.4.11/examples
)
Also note that -I
is a non-standard option for m4, so make sure you are actually using a version of m4
that supports that argument. (eg, gnu-m4
)