[Top][All Lists]

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

Re: Bug

From: John Calcote
Subject: Re: Bug
Date: Sat, 22 Aug 2009 15:38:19 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20090715 Thunderbird/3.0b3

On 8/21/2009 9:14 AM, Yuri Shtil wrote:
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)

   @echo DONE

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

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

define FUNC
###FOO := $(shell sleep 10)
        @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

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.

You have to admit that Yuri has a valid point here. 99.9999 percent of all developers know that a hash mark starts a comment, wherein the following text is ignored until the next newline. .0001 percent of developers have read the GNU make manual /closely enough/ to understand that under certain conditions, a hash mark doesn't necessarily mean that the following text is ignored till the next newline.



reply via email to

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