bugmake - Bugs: bug #7310, comments are not ignored in...

 
 

bug #7310: comments are not ignored in $(call) /$(eval)

Submitted by:  Boris Kolpackov <bosk>
Submitted on:  Sun 18 Jan 2004 05:36:40 AM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: Not A BugPrivacy: Public
Assigned to: Paul D. Smith <psmith>Open/Closed: Closed
Component Version: 4.0Operating System: Any
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 19 Jan 2004 05:50:53 AM UTC, comment #1:

Your evaluation is not quite correct. Comments ARE ignored. However, in the example above the warning function is evaluated before the comment comes into effect.

Values inside a define/endef do not undergo treatment to remove comments: the lines inside that block are assigned verbatim to the variable.

Next, the call function is invoked on variable "foo", with an argument of "baz". That is completely expanded and the results of that expansion are passed to the eval function to be evaluated.

When the call function evaluates the foo variable as a function, it is not examined for comment characters first, because normally these are stripped off when the value is read in. Because of that, the warning function is evaluated at that time, and the warning is printed. The $(eval ...) reference here is a red herring: you would get the same output if you'd invoked just $(call ...) by itself. By the time the eval function gets the value the warning has been printed and replaced with an empty string, so eval just sees the string "#", which it properly ignores as a comment.

I don't see any way to change this behavior; if call were changed to check for comments then first, that would not be a backward-compatible change, and second we'd have to change all the other functions in that way as well, to be consistent. I'm not even sure it's really incorrect behavior, per se, although I grant you it's surprising at first. But, when using call and eval it's critically important to be very familiar with evaluation of variables, where it happens, and how it works.

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Sun 18 Jan 2004 05:36:40 AM UTC, original submission:

$ cat > comment

define foo
#$(warning $(1))
endef

define bar
$(eval $(call foo,baz))
endef

$(call bar)

$ make -f comment
comment:8: baz
make: *** No targets. Stop.

Boris Kolpackov <bosk>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 3 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Mon 19 Jan 2004 05:50:53 AM UTCpsmithStatusNone=>Not A Bug
  Assigned toNone=>psmith
  Open/ClosedOpen=>Closed

Back to the top


Powered by Savane 3.1-cleanup1