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

File: autoconf.info,  Node: Comments in Make Macros,  Next: Trailing whitespace in Make Macros,  Prev: Newlines in Make Rules,  Up: Portable Make

12.13 Comments in Make Macros
=============================

In macro definitions, text from ‘#’ until line end is ignored, which has
the unfortunate effect of disallowing ‘#’ even in quotes.  Thus, the
following does not work:

     CPPFLAGS = "-DCOMMENT_CHAR='#'"

as ‘CPPFLAGS’ is expanded to ‘"-DCOMMENT_CHAR='’.

   GNU ‘make’, when not in POSIX mode, lets you put ‘#’ into a macro
value by escaping it with a backslash, i.e., ‘\#’.  However, this usage
is not portable.  *Note Comments in Make Rules::, for a portable
alternative.

   Even without quoting involved, comments can have surprising effects,
because the whitespace before them is part of the variable value:

     foo = bar # trailing comment
     print: ; @echo "$(foo)."

prints ‘bar .’, which is usually not intended, and can expose ‘make’
bugs as described below.

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