bug-make
[Top][All Lists]
Advanced

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

[bug #54727] foreach variable is not visible for a target specific varia


From: Michael Builov
Subject: [bug #54727] foreach variable is not visible for a target specific variable definition in a recipe
Date: Thu, 4 Oct 2018 09:52:41 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0

Follow-up Comment #3, bug #54727 (project make):

It also possible to step on this "foreach + eval" bug not in a recipe.

Please consider the next example:

############
# define global variable
f := g

# function for defining target-specific variables
# $1 - target
# $2 - variable
def_target_specific = $(foreach f,1,$(eval $1: $2:=$$f))

# calling in global context: M=1
$(call def_target_specific,target_X,M)

# calling in target-specific context: M=g
all: TMP := $(call def_target_specific,target_Y,M)

all: target_X target_Y
target_X target_Y:; $(info $@: M=$M)
############

result:

target_X: M=1
target_Y: M=g



As we can see, the variable M has different values for target_X and target_Y,
which is not expected.

Outer foreach variables cannot be used inside the eval context, if the call
comes from a target-specific variable definition.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?54727>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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