bug-make
[Top][All Lists]
Advanced

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

Re: Bug using computed variable names together with call


From: Paul D. Smith
Subject: Re: Bug using computed variable names together with call
Date: Tue, 2 Jul 2002 09:37:47 -0400

%% Onno Garms <address@hidden> writes:

  og> I think I've found a bug in gnu make.

Not a bug in make.

  og> The bug occurs when using computed variable names together with
  og> call. I expected gmake to echo "b" twice in the last
  og> command. However it echoed an empty string and "b".

  og> Computed variable names like in test1 seem not to work together
  og> with call while the workarround in test2 works.

  og> a = b
  og> test1 = $($(1))
  og> test2 = $($(shell echo $(1)))

  og>         @echo $(call test1, a)
  og>         @echo $(call test2, a)

The problem is with the extra whitespace you have before "a".

Whitespace _is_ significant within function arguments: it is preserved
by make.  The only whitespace inside functions which is discarded is the
space(s) between the function name and the first argument.

Most of the time extra whitespace doesn't hurt anything, but in this
case you are using the value of "a" as a variable name.  While you have
defined a variable "a", you have not defined a variable " a".  The first
call expands this way where $(1) is set to " a":

  $($(1))  ->  $( a)  ->  [empty; no such variable " a"]

The second one works because the shell ignores the extra whitespace for
you:

  $($(shell echo $(1))) -> $($(shell echo  a)) -> $(a) -> b

Change your call line like this:

        @echo $(call test1,a)

and it will work.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "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]