gpt4 book ai didi

string - 生成文件: contains string

转载 作者:行者123 更新时间:2023-12-03 05:33:49 25 4
gpt4 key购买 nike

变量返回MINGW32_NT-5.1CYGWIN_NT-5.1。(是的,末尾有点)

需要比较给定的 var 是否包含位于任意位置的 NT-5.1

使用 cygwin 并希望与几乎任何 *nix 兼容。

最佳答案

findstring功能是您内心的渴望:

$(findstring find,in)

Searches in for an occurrence of find. If it occurs, the value is find; otherwise, the value is empty. You can use this function in a conditional to test for the presence of a specific substring in a given string. Thus, the two examples,

$(findstring a,a b c)
$(findstring a,b c)

produce the values "a" and "" (the empty string), respectively. See Testing Flags, for a practical application of findstring.

类似于:

ifneq (,$(findstring NT-5.1,$(VARIABLE)))
# Found
else
# Not found
endif

What is the comma here for ifneq (,$(...?

将其解析为 ifneq(A,B),其中 A 是空字符串,B$(findstring.. .)。这看起来很奇怪,因为您没有在 Makefile 中引用字符串。

关于string - 生成文件: contains string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2741708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com