[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug? $(warning)/$(error) evaluated from inside a comment in a 'defin

From: Philip Guenther
Subject: Re: bug? $(warning)/$(error) evaluated from inside a comment in a 'define'?
Date: Tue, 19 Jun 2007 23:39:38 -0600

On 6/19/07, Stephan Beal <address@hidden> wrote:
When a $(warning) or $(error) is inside a 'define', it is evaluated even
if it is part of a comment.

The above statement is nonsensical.  If something is inside a define,
is not inside a comment.

define bogo
   # $(warning this should not be evaluated here: (bogo $(1)))
   abc := $(1)
$(foreach ARG,abc def ghi,$(eval $(call bogo,$(ARG))))

Okay, so you've defined a variable, 'bogo', whose value consists of
two lines, the first of which has a '#' as its first non-whitespace
character.  It isn't a comment at that point, it's just a line with a
leading '#'.

So why isn't it being treated as a comment when you evaluate it?
Answer: it *is*, but the expansion of the variables and functions in
the value of 'bogo' takes place before 'eval' does anything.  Consider

define bogo2
# $(warning foo! $(1))
       echo '$(bogo2)'
       echo '$(call bogo2,baz)'
$ gmake -f m2
m2:6: foo!
m2:6: foo! baz
echo '# '
echo '# '

When $(bogo2) is expanded, whether directly or via $(call), make
recursively expands the variables and functions inside its value.
That's all without $(eval) being used at all.

As far as i understand, comments are comments, regardless of the
context. ???

Not at all.  A comment is only a comment when being read, either as
part of the raw makefile or as the first step in eval's actual

(Then there are comments in the commands for rules, where if they're
indented with a tab then make sees them as normal parts of the
commands and passes them to the shell...which then will often ignore
them based on *its* rules.)

Philip Guenther

reply via email to

[Prev in Thread] Current Thread [Next in Thread]