[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
To call or not to call
From: |
Ken Smith |
Subject: |
To call or not to call |
Date: |
Tue, 26 Apr 2005 16:35:48 -0400 |
User-agent: |
Mutt/1.5.9i |
I have experienced some strange behavior with call and eval which I'd
like to share. I think I know how to work around the problem I'm
experiencing but I'd like to know why I'm seeing this behavior. First,
the makefiles.
% cat test1.mk
define __func
return_value:=0
endef
func=$(eval $(__func))$(return_value)
my_retval:=$(func)
all:
@echo my_retval=$(my_retval)
@echo return_value=$(return_value)
% cat test2.mk
define __func
return_value:=0
endef
func=$(eval $(__func))$(return_value)
my_retval:=$(call func)
all:
@echo my_retval=$(my_retval)
@echo return_value=$(return_value)
% diff test1.mk test2.mk
7c7
< my_retval:=$(func)
---
> my_retval:=$(call func)
I read in the GNU make manual that "it doesn't make sense to use call
with no parameters" so I figured I'd be fine with $(func). It turns out
that the output of `gmake -f test1.mk' looks quite strange.
% gmake -f test1.mk
my_retval=0ue:=0
return_value=0
Whereas the output of `gmake -f test2.mk' matches my expectations.
% gmake -f test2.mk
my_retval=0
return_value=0
Can someone tell me why?
Ken
- To call or not to call,
Ken Smith <=