Copyright (C) 2000-2012 |
GNU Info (autoconf.info)Quotation Rule Of ThumbQuotation 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 <time.h> #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 <time.h> #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 will 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 <time.h> #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]) See 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 will contain unexpanded macros. The `autoconf' program checks for this problem by doing `grep AC_ configure'. automatically generated by info2www version 1.2.2.9 |