Autoconf: dnl vs. #

DevSolar picture DevSolar · Jul 30, 2010 · Viewed 12.6k times · Source

The Autoconfig manual states that comment lines can start with either dnl or #.

Is there any difference between them, any reason to use one rather than the other in any circumstance? Or is it purely a matter of taste?

Answer

William Pursell picture William Pursell · Jul 31, 2010

In configure.ac, lines commented with '#' that occur after AC_INIT will appear in the resulting configure script. dnl comments will not. One purpose of dnl is to discard unwanted newlines in an effort to make the configure script readable. Also, it is appropriate to use dnl comments to document an m4 macro; those comments make no sense in the configure script, since the m4 macro does not appear there, only its expansion.

Comments in Makefile.am are treated differently. Makefile.am is not processed by m4, but by automake, where the convention is to discard lines which begin with ## preceded only by whitespace. (Although ### comments carry through to the Makefile.in) Since Makefile.am is not processed by m4, 'dnl' does not introduce a comment.