manpagez: man pages & more
info autoconf
Home | html | info | man

File: autoconf.info,  Node: Active Characters,  Next: One Macro Call,  Up: M4 Quotation

8.1.1 Active Characters
-----------------------

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(1), ‘(’ 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 results(2)?

   ---------- Footnotes ----------

   (1) By itself, M4 uses ‘`’ and ‘'’; it is the M4sugar layer that sets
up the preferred quotes of ‘[’ and ‘]’.

   (2) Using ‘defn’.

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.