macros - 如何在 GNU Make 中使用 $(call ...) 执行可变宏

标签 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)

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

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/

相关文章:

macros - &allow-other-keys ,它有什么作用? - 普通口齿不清

makefile - 从 Makefile 规则打印粗体或彩色文本

c++ - 可变参数宏是非标准的吗?

c - 可变参数宏包装器,可扩展为具有与参数数量对应的字符的格式字符串

c - 在 C/C++ 宏中通过 __VA_ARGS__ 迭代添加分隔符

c++ - 为什么字符串连接宏不适用于这个 "+"案例?

ios - 将 UIColor 值分配给宏

macros - 用于创建函数变体的 Haxe 宏

c++ - 有没有办法计算出所有必需的依赖项,但不执行 "./configure"- C

makefile - 包含生成的 makefile 没有警告消息