To fully understand where proper quotation is important, you first need to know what the special characters are in Autoconf: ‘#’ introduces a comment inside which no macro expansion is performed, ‘,’ separates arguments, ‘[’ and ‘]’ are the quotes themselves, ‘(’ and ‘)’ (which M4 tries to match by pairs), and finally ‘$’ inside a macro definition.
In order to understand the delicate case of macro calls, we first have to present some obvious failures. Below they are “obvious-ified”, but when you find them in real life, they are usually in disguise.
Comments, introduced by a hash and running up to the newline, are opaque tokens to the top level: active characters are turned off, and there is no macro expansion:
# define([def], ine) ⇒# define([def], ine)
Each time there can be a macro expansion, there is a quotation expansion, i.e., one level of quotes is stripped:
int tab[10]; ⇒int tab10; [int tab[10];] ⇒int tab[10];
Without this in mind, the reader might try hopelessly to use her macro
array
:
define([array], [int tab[10];]) array ⇒int tab10; [array] ⇒array
How can you correctly output the intended results1?