如何在GNU Make中使用$(call ...)进行可变参数宏

Bri*_*erg 4 macros gnu-make variadic-macros

我创建了一个用于makefile的宏:

TODO_MSG = $(warning TODO: $(1))
$(call TODO_MSG, This part of the msg displays fine, but this part does not)
Run Code Online (Sandbox Code Playgroud)

我可以通过以下方式解决这个问题:

BLAH := $(shell perl -e 'print join( " ", 2..200 )'
COMMA := ,
TODO_MSG = $(warning TODO:$(1)$(strip $(foreach x,${BLAH},$(if $(${x}),${COMMA}$(${x}))))
Run Code Online (Sandbox Code Playgroud)

...但我很好奇是否有任何东西可以为变量宏提供更明确的支持.

Cla*_*ley 6

以下是Beta解决方案的混音:

TODO_MSG = $(warning TODO: $(1))

test:
        $(call TODO_MSG, $(strip This part displays fine, and this does too))
Run Code Online (Sandbox Code Playgroud)

如果Make有$(identity ...)函数,我会使用它; $(strip ...)是我能找到的最接近的.