autoconf: One Macro Call
1
1 8.1.2 One Macro Call
1 --------------------
1
1 Let's proceed on the interaction between active characters and macros
1 with this small macro, which just returns its first argument:
1
1 define([car], [$1])
1
1 The two pairs of quotes above are not part of the arguments of
1 `define'; rather, they are understood by the top level when it tries to
1 find the arguments of `define'. Therefore, assuming `car' is not
1 already defined, it is equivalent to write:
1
1 define(car, $1)
1
1 But, while it is acceptable for a `configure.ac' to avoid unnecessary
1 quotes, it is bad practice for Autoconf macros which must both be more
1 robust and also advocate perfect style.
1
1 At the top level, there are only two possibilities: either you quote
1 or you don't:
1
1 car(foo, bar, baz)
1 =>foo
1 [car(foo, bar, baz)]
1 =>car(foo, bar, baz)
1
1 Let's pay attention to the special characters:
1
1 car(#)
1 error-->EOF in argument list
1
1 The closing parenthesis is hidden in the comment; with a hypothetical
1 quoting, the top level understood it this way:
1
1 car([#)]
1
1 Proper quotation, of course, fixes the problem:
1
1 car([#])
1 =>#
1
1 Here are more examples:
1
1 car(foo, bar)
1 =>foo
1 car([foo, bar])
1 =>foo, bar
1 car((foo, bar))
1 =>(foo, bar)
1 car([(foo], [bar)])
1 =>(foo
1 define([a], [b])
1 =>
1 car(a)
1 =>b
1 car([a])
1 =>b
1 car([[a]])
1 =>a
1 car([[[a]]])
1 =>[a]
1