May 30, 2007

Multi-line Comments in Make

You see, this is why I hate Make. Did you know that a backslash at the end of a comment line extends the comment to the next line? For example:

# This is a comment \
and this is still a comment

This is all very nice and logical—a trailing backslash means the same thing no matter where it appears in a file—but it has all the niceness and logic just exactly backwards. The behavior of (line-based) comments in every other programming environment I know of is: a comment character (in this case ‘#‘) introduces a comment that is terminated by the end of the line; if a line is not preceded by a comment character, it is not a comment.

This may seem harmless. But consider the following:

FILES = \
file1 \
file2 \
file3

Now suppose we decide to temporarily remove file1:

FILES= \
# file1 \
file2 \
file3

Does FILES equal "file2 file3"? No! FILES is empty. And that’s if you’re lucky and you didn’t get some weird syntax error.

Advertisements

Share this:

Like this:

LikeLoading...

Related

Comments Off on Multi-line Comments in Make

Search for:

About

A place to document tips and tricks for the various Linux, LaTeX, OCaml, and other general computer-related topics that I encounter in my daily life and a repository for supposedly amusing observations, hyperlinks, recipes, reviews, travelogues, and political opinions written when I have a spare moment (or when I don't have a spare moment, but I don't feel like working)