使用Addprefix函数使该字符串与其他字符串无法比较 [英] Using Addprefix function makes the string uncomparable to another string
问题描述
所以,我有以下代码:
OBJ:= $(addprefix'obj_',$(basename $ notdir /build/common.mk)))
所以现在OBJ1是obj_common / strong>
ifeq($(OBJ),obj_common)
@echo等于(**不知道如何在此网站中缩排缩进。**)
endif
ifeq无法将$(OBJ)与obj_common进行比较,至少没有回显...
(但是,如果我摆脱addprefix函数如下:)
OBJ:= $(basename $(notdir /build/common.mk))
所以现在OBJ1是常用
ifeq($(OBJ),common)
/ pre>
@echo等于
endif
这段代码将回应,这意味着他们可以比较和平等。
我需要引用变量
$(OBJ_common)
(I hav这是一个很大的列表,所以我不能手动输入字符串手),但现在addprefix函数使这个字符串不是一个字符串...
任何人可以帮我解决问题?如果我的问题不清楚,请告诉我。非常感谢。解决方案嗯,这个错误在下面的陈述中:
OBJ:= $(addprefix'obj_',$(basename $(notdir /build/common.mk)))
所以现在OBJ1是obj_common
其实
OBJ1
成为'obj'_common
,因为您在第一个参数中使用的引号addprefix
。
所以没有引号就可以正常工作:
OBJ:= $(addprefix obj_,$(basename $(notdir /build/common.mk)))
提示
使用
警告
和错误
用于调试脚本的功能: b
OBJ:= ...
$(警告现在OBJ1是[$(OBJ1)])
So, I have the following code:
OBJ := $(addprefix 'obj_', $(basename $(notdir /build/common.mk)))
so now OBJ1 is "obj_common"
ifeq ($(OBJ),obj_common) @echo equal (**don't know how to format indent in this website..assume there is.**) endif
the ifeq can't compare $(OBJ) to obj_common, at least it didn't echo...
(However, if I get rid of addprefix function as follow:)
OBJ := $(basename $(notdir /build/common.mk))
so now OBJ1 is "common"
ifeq ($(OBJ),common) @echo equal endif
this code would echo, which means they can compare and are equal.
I need to reference the variable
$(OBJ_common)
(I have a big list of this kind of variable, so I can't manually input the string by hand), but now addprefix function makes this string not a string... Could anyone please help me resolve the issue? If my question is not clear, please let me know. Thank you very much.解决方案Well, the mistake is in the following statement:
OBJ := $(addprefix 'obj_', $(basename $(notdir /build/common.mk))) so now OBJ1 is "obj_common"
In fact,
OBJ1
becomes'obj'_common
because of quotes that you used in the first argument toaddprefix
.So without the quotes it should work fine:
OBJ := $(addprefix obj_, $(basename $(notdir /build/common.mk)))
Tip
Use
warning
anderror
functions for debugging your scripts:OBJ := ... $(warning so now OBJ1 is [$(OBJ1)])
这篇关于使用Addprefix函数使该字符串与其他字符串无法比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!