我创建了一个在 makefile 中使用的宏,内容如下:
TODO_MSG = $(warning TODO: $(1))
$(call TODO_MSG, This part of the msg displays fine, but this part does not)
我可以通过以下方式解决这个问题:
BLAH := $(shell perl -e 'print join( " ", 2..200 )'
COMMA := ,
TODO_MSG = $(warning TODO:$(1)$(strip $(foreach x,${BLAH},$(if $(${x}),${COMMA}$(${x}))))
...但我很好奇是否有任何东西可以为可变参数宏提供更明确的支持。
最佳答案
这是 Beta 解决方案的混音版:
TODO_MSG = $(warning TODO: $(1))
test:
$(call TODO_MSG, $(strip This part displays fine, and this does too))
如果 Make 有一个 $(identity ...) 函数,我会使用它; $(strip ...) 是我能找到的最接近的。
关于macros - 如何在 GNU Make 中使用 $(call ...) 执行可变宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12168913/