![]() |
读研的枕头 · [PATCH 4/6] ...· 1 月前 · |
![]() |
烦恼的四季豆 · Compilation error for ...· 1 周前 · |
![]() |
健身的铁链 · What packages are ...· 1 周前 · |
![]() |
干练的地瓜 · 雪松好玩吗 雪松玩法简介_雪松_九游手机游戏· 2 月前 · |
![]() |
严肃的机器人 · 如何解读单反相机镜头的MTF图_中摄网(ww ...· 4 月前 · |
![]() |
很拉风的丝瓜 · Handheld Inkjet ...· 5 月前 · |
![]() |
热情的烤面包 · douban/intro.txt at ...· 5 月前 · |
![]() |
听话的麻辣香锅 · React 入门实例 ...· 5 月前 · |
赋值语句 字符串函数 python字符串比较 makefile |
https://cloud.tencent.cn/developer/information/%E4%BB%8Emakefile%E4%B8%AD%E7%9A%84%E5%8F%98%E9%87%8F%E4%B8%AD%E6%8F%90%E5%8F%96%E5%AD%90%E5%AD%97%E7%AC%A6%E4%B8%B2 |
![]() |
重情义的炒粉
5 月前 |
在makefile中,可以使用字符串操作函数来提取子字符串。以下是一些常用的字符串操作函数:
$(subst from,to,text)
: 将字符串
text
中的所有
from
替换为
to
。
$(patsubst pattern,replacement,text)
: 将字符串
text
中符合模式
pattern
的部分替换为
replacement
。
$(strip string)
: 去除字符串
string
中开头和结尾的空格。
$(findstring find,text)
: 在字符串
text
中查找子字符串
find
,如果找到返回
find
,否则返回空字符串。
$(filter pattern...,text)
: 从字符串
text
中筛选出符合模式
pattern
的部分。
$(wildcard pattern)
: 返回符合模式
pattern
的文件名列表。
下面是一个示例,展示如何从makefile中的变量中提取子字符串:
# 定义一个变量
VAR := hello_world
# 提取子字符串
SUBSTR := $(subst hello_,,$(VAR))
# 输出结果
$(info $(SUBSTR))
输出结果为:
world
在这个示例中,我们定义了一个变量
VAR
,其值为
hello_world
。然后使用
$(subst)
函数将
hello_
替换为空字符串,得到了子字符串
world
。最后使用
$(info)
函数输出结果。
对于makefile中的变量提取子字符串的应用场景,可以根据具体需求进行灵活运用。例如,可以用于从文件名中提取特定部分、从路径中提取文件名等。根据不同的需求,可以选择合适的字符串操作函数来提取所需的子字符串。
腾讯云相关产品和产品介绍链接地址:
![]() |
读研的枕头 · [PATCH 4/6] scripts/dtc: generate lexer and parser during build instead of shipping - Rob Herring 1 月前 |
![]() |
干练的地瓜 · 雪松好玩吗 雪松玩法简介_雪松_九游手机游戏 2 月前 |