GNU make manual 翻译( 一百六十三)
发布日期:2021-09-02 01:09:58 浏览次数:1 分类:技术文章

本文共 1547 字,大约阅读时间需要 5 分钟。

继续翻译

6.6 Appending More Text to Variables====================================Often it is useful to add more text to the value of a variable alreadydefined.  You do this with a line containing `+=', like this:     objects += another.oThis takes the value of the variable `objects', and adds the text`another.o' to it (preceded by a single space).  Thus:     objects = main.o foo.o bar.o utils.o     objects += another.osets `objects' to `main.o foo.o bar.o utils.o another.o'.   Using `+=' is similar to:     objects = main.o foo.o bar.o utils.o     objects := $(objects) another.obut differs in ways that become important when you use more complexvalues.   When the variable in question has not been defined before, `+=' actsjust like normal `=': it defines a recursively-expanded variable.However, when there _is_ a previous definition, exactly what `+=' doesdepends on what flavor of variable you defined originally.  *Note TheTwo Flavors of Variables: Flavors, for an explanation of the twoflavors of variables.

6.6 给变量追加更多文本

====================================

给一个已经定义好的变量追加更多的文本经常是很有用的。你可以用一行包含+=的行来做这件事。向这样:

objects += another.o

这将获得变量objects得值,然后把another.o 追加到它后面(前面放一个空格)。因此:

objects = main.o foo.o bar.o utils.o

objects += another.o

设置 `objects' 为 `main.o foo.o bar.o utils.o another.o'。

Using `+=' 等同于:

objects = main.o foo.o bar.o utils.o

objects := $(objects) another.o

但是当你使用更加复杂的值的时候,其差异就变得重要了。

当上述问题中的变量没有被定义的时候,+=就像通常的=: 一样,它定义了一个递归的变量。但是当变量已经有了定义,+=要做的依赖于你事前定义此变量所用的风格。关于变量两种风格,参照 *Note the Tow Flavors of Variables: Flavors

后文待续

转载地址:https://blog.csdn.net/weixin_34129696/article/details/85519701 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:正则表达式
下一篇:GNU make manual 翻译(三十)

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月22日 06时44分59秒