manpagez: man pages & more
info autoconf
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.13 Comments in Make Macros

Avoid putting comments in macro values as far as possible. Posix specifies that the text starting from the ‘#’ sign until the end of the line is to be ignored, which has the unfortunate effect of disallowing them even within quotes. Thus, the following might lead to a syntax error at compile time:


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

Most make implementations disregard this and treat single and double quotes specially here. Also, GNU make lets you put ‘#’ into a macro value by escaping it with a backslash, i.e., ‘\#’. However, neither of these usages are portable. See section 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.

This document was generated on April 26, 2012 using texi2html 5.0.

© 2000-2019
Individual documents may contain additional copyright information.