bug-make
[Top][All Lists]
Advanced

[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: Paul Smith
Subject: Re: bug? $(warning)/$(error) evaluated from inside a comment in a 'define'?
Date: Wed, 20 Jun 2007 08:45:16 -0400

On Tue, 2007-06-19 at 20:50 +0200, Stephan Beal wrote:
> When a $(warning) or $(error) is inside a 'define', it is evaluated
> even if it is part of a comment.

Others have responded with all the info but I'm not sure everyone
understood it.

There are two factors at work here.

First, note that make does not do comment processing inside a define
statement.  If you add a "#" inside a define, then that literal
character "#" (plus the rest of the line) is present in the value of the
variable being defined.  In fact nothing is parsed inside a define.  I'm
not sure, from your message, if this is what you feel is the surprising
behavior; to me it seems exactly the way things should work.  Think of a
define as kind of like single-quoted strings in the shell: no special
characters are evaluated.

Second, note that comment characters IN COMMAND SCRIPTS are not
interpreted by make as make comments, either.  That is this:

        foo:
        # bar

is a target "foo" with a comment after it and no command script, while
this:

        foo:
                # bar

is a target "foo" with a command script of "# bar", which passed to the
shell as normal and may or may not end up being a comment in the shell.

So, when you put a variable $(foo) in a command script (preceded by a
TAB) and it's expanded, the expanded value is not parsed for make
comments.  The "#" and following text is kept.

Then, of course, before make invokes the shell it expands the script,
and when that happens the $(warning ...) or $(info ...) or whatever else
is evaluated.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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