File: autoconf.info, Node: Quotation Rule Of Thumb, Prev: Balancing Parentheses, Up: M4 Quotation 8.1.8 Quotation Rule Of Thumb ----------------------------- To conclude, the quotation rule of thumb is: _One pair of quotes per pair of parentheses._ Never over-quote, never under-quote, in particular in the definition of macros. In the few places where the macros need to use brackets (usually in C program text or regular expressions), properly quote _the arguments_! It is common to read Autoconf programs with snippets like: AC_TRY_LINK( changequote(<<, >>)dnl <<#include#ifndef tzname /* For SGI. */ extern char *tzname[]; /* RS6000 and others reject char **tzname. */ #endif>>, changequote([, ])dnl [atoi (*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no) which is incredibly useless since ‘AC_TRY_LINK’ is _already_ double quoting, so you just need: AC_TRY_LINK( [#include #ifndef tzname /* For SGI. */ extern char *tzname[]; /* RS6000 and others reject char **tzname. */ #endif], [atoi (*tzname);], [ac_cv_var_tzname=yes], [ac_cv_var_tzname=no]) The M4-fluent reader might note that these two examples are rigorously equivalent, since M4 swallows both the ‘changequote(<<, >>)’ and ‘<<’ ‘>>’ when it “collects” the arguments: these quotes are not part of the arguments! Simplified, the example above is just doing this: changequote(<<, >>)dnl <<[]>> changequote([, ])dnl instead of simply: [[]] With macros that do not double quote their arguments (which is the rule), double-quote the (risky) literals: AC_LINK_IFELSE([AC_LANG_PROGRAM( [[#include #ifndef tzname /* For SGI. */ extern char *tzname[]; /* RS6000 and others reject char **tzname. */ #endif]], [atoi (*tzname);])], [ac_cv_var_tzname=yes], [ac_cv_var_tzname=no]) Please note that the macro ‘AC_TRY_LINK’ is obsolete, so you really should be using ‘AC_LINK_IFELSE’ instead. *Note Quadrigraphs::, for what to do if you run into a hopeless case where quoting does not suffice. When you create a ‘configure’ script using newly written macros, examine it carefully to check whether you need to add more quotes in your macros. If one or more words have disappeared in the M4 output, you need more quotes. When in doubt, quote. However, it's also possible to put on too many layers of quotes. If this happens, the resulting ‘configure’ script may contain unexpanded macros. The ‘autoconf’ program checks for this problem by looking for the string ‘AC_’ in ‘configure’. However, this heuristic does not work in general: for example, it does not catch overquoting in ‘AC_DEFINE’ descriptions.