[Top][All Lists]

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

Missing arguments to macros

From: Robert Mecklenburg
Subject: Missing arguments to macros
Date: Wed, 6 Nov 2002 10:49:15 -0700

# This messsage can be executed by make to illustrate my problem.
all: ; @$(call f,a,b)

# The details of macro argument processing aren't clear to me, so I'm
# asking.  It appears that all macro arguments are optional, for
# instance:

define g
  $1 $2

# The macro g can be called with any number of arguments, e.g.,
# "$(call g,a)" or "$(call g,a,b,c)".  Extra arguments are never
# expanded/substituted and missing arguments have an empty value.  Is
# this correct?

# If the above is correct, then I experience an issue when macros call
# other macros.  For instance, here "f" takes two arguments, but
# passes only one of them to "g" omitting the second argument.

define f
  # Use $1 somehow...
  echo $(call g,$2)

# Here lies the issue.  Even though "g" receives only one argument,
# "$2" still has the value from "f".  I expect this makefile to print
# simply "b", but it prints "b b".  Is this correct?

# If I add a comma like this "$(call g,$2,)" (providing an empty
# second argument) the code works as expected.


reply via email to

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