help-make
[Top][All Lists]
Advanced

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

Re: Bug


From: Yuri Shtil
Subject: Re: Bug
Date: Fri, 21 Aug 2009 08:14:56 -0700
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Philip Guenther wrote:
On Thursday, August 20, 2009, Yuri Shtil <address@hidden> wrote:
It look like the shell function is evaluated even though commented out in the 
following code:

define FUNC
###FOO := $(shell sleep 10)
endef

all:
   @echo DONE

$(eval $(call FUNC,$(platform)))

What's so surprising?  The $(shell) is evaluated in the following too:

define FUNC
###FOO := $(shell sleep 10)
endef
all:
        @echo DONE
noop =
$(noop $(call FUNC,$(platform)))

And ditto if you replace the last line with

$(noop $(FUNC))

In each case, FUNC has to be expanded to determine the argument to a
function.  In your post, that function is $(eval), in mine it's
$(noop).

The argument to $(eval) is expanded TWICE: one before $(eval) 'starts'
and then once by $(eval).  If you don't understand that and choose
when each variable should be expanded, the results will be fragile.
It may be subtle and only show up when you decide to reference both
normal and automatic variables or a variable that contains shell
commands using shell variables...which just means you're laying a trap
for a time when you've forgotten the details.

Philip Guenther
What is surprising is that a line segment starting with a hash sign must be ignored up to the end of the line, this is the whole purpose of having comments in the code.


--

Yuri





reply via email to

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