为什么将可选的“=”添加到 gnu make 4 的定义指令中?
Why was the optional '=' added to the define directive of gnu make 4?
查看 Defining multi-line variables 的 Gnu make 4.2 手册,我们看到一个示例:
define two-lines =
echo foo
echo $(bar)
endef
和评论
The define directive is followed on the same line by the name of the variable being defined and an (optional) assignment operator, and nothing more.
我曾多次被包含可选的 =
绊倒,然后在使用 Gnu make 3.81 在不同的机器上构建时遇到(通常是微妙的)问题。当然,我不应该在 运行 3.81 时使用 4.2 语法!但是我发现这是一个很容易犯的错误,尤其是因为 URL 和 1 的内容都没有指明正在记录的版本(您必须单击 Up
2 级才能看到版本)。
那么,回到我的问题:为什么要引入可选的 =
?
它允许您使用所有不同的赋值运算符创建宏。特别是它允许您使用:
define foo :=
得到一个简单展开的变量,或者
define foo ?=
获取可选分配的变量等。作为其中的一部分,您可以使用(冗余)
define foo =
还有。
查看 Defining multi-line variables 的 Gnu make 4.2 手册,我们看到一个示例:
define two-lines =
echo foo
echo $(bar)
endef
和评论
The define directive is followed on the same line by the name of the variable being defined and an (optional) assignment operator, and nothing more.
我曾多次被包含可选的 =
绊倒,然后在使用 Gnu make 3.81 在不同的机器上构建时遇到(通常是微妙的)问题。当然,我不应该在 运行 3.81 时使用 4.2 语法!但是我发现这是一个很容易犯的错误,尤其是因为 URL 和 1 的内容都没有指明正在记录的版本(您必须单击 Up
2 级才能看到版本)。
那么,回到我的问题:为什么要引入可选的 =
?
它允许您使用所有不同的赋值运算符创建宏。特别是它允许您使用:
define foo :=
得到一个简单展开的变量,或者
define foo ?=
获取可选分配的变量等。作为其中的一部分,您可以使用(冗余)
define foo =
还有。