defined(name[, type])是qmake中的Build-in test function,其意义是用于判断name是否已经被定义了,可以判断qmake中的变量名、自定义repace函数名、自定义test函数名是否已经被定义。

关于qmake自定义函数可以参考:qmake自定义函数_Qt君的博客-CSDN博客_qmake 自定义函数

实际操作大致与文档介绍相同,只是对build-in function进行测试时是无法检测出来的。

type参数有test、replace、var三个可选项。如果没有type参数,检测是否是自定义的test函数或replace函数;如果使用test参数,则检测是否是自定义的test函数;如果使用replace参数则检测是否是自定义的replace函数;如果使用var参数,则检测是否是变量,包括内部定义的CONFIG、TEMPLATE等变量。
Tests whether the function or variable name is defined. If type is omitted, checks all functions. To check only variables or particular type of functions, specify type. It can have the following values:

  • test only checks test functions
  • replace only checks replace functions
  • var only checks variables
tt=true
ttv=123
tt1=  #定义空变量message($$tt)  #输出true
message($$ttv) #输出123defineTest(mytt){  #自定义函数mytt,传入参数个数是没有限制的,使用哪些个参数是内部的事情message($$ARGS)var=$$1  #$${1} 与 $$1等价varvalue=$$eval($${1})  #获取变量的值需要双重$$,需要通过eval 这个replace函数来获取message(--{1}=$${1})message(--var=$$var)message(--varvalue=$$varvalue)
}mytt(ttv)  #注意defineTest函数传入的参数是ttv这个变量名
#输出:
#ttv
#--{1}=ttv
#--var=ttv
#--varvalue=123
mytt(ttv,tt1)  #mytt中只使用第一个参数,再多的参数虽然合法但是没有意义。
#输出:
#ttv tt1
#--{1}=ttv
#--var=ttv
#--varvalue=123defineReplace(myfunc) {variable = $$ARGSnames = $$eval($$variable)tname = $$1message($$ARGS)for(name, variable) {equals(name,33):tname=$$name}return($$tname)
}defineTest(allFiles) {files = $$ARGSfor(file, files) {!exists($$file) {return(false)}}return(true)
}VAR=defined(CONFIG,var){message(here1)  //输出
}else{message(here2)
}defined(allFiles){message(here3)  //输出
}else{message(here4)
}
defined(allFiles,test){message(here5)  //输出
}else{message(here6)
}
defined(allFiles,replace){message(here7)
}else{message(here8)  //输出
}
defined(myfunc){message(here9)  //输出
}else{message(here10)
}
defined(myfunc,test){message(here11)
}else{message(here12)  //输出
}
defined(myfunc,replace){message(here13)  //输出
}else{message(here14)
}
defined(load){message(here15)
}else{message(here16)  //输出
}
defined(VAR){message(here17)
}else{message(here18)  //输出
}
defined(VAR,var){message(here19)  //输出
}else{message(here20)
}

杂谈

//E:\workspace\QtWork\qmake\library\qmakebuiltins.cpp
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(const QMakeInternal::QMakeBuiltin &adef, const ProKey &function, const ProStringList &args)
{
m_functionDefs.testFunctions存放自定义的test函数,内置的test函数存放在static.functions中
m_functionDefs.replaceFunctions存放自定义的replace函数,内置的replace函数存放在static.expands中。defined并没有对内置函数进行查找。
........case T_DEFINED: {  const ProKey &var = args.at(0).toKey();if (args.count() > 1) {if (args[1] == QLatin1String("test")) {return returnBool(m_functionDefs.testFunctions.contains(var));} else if (args[1] == QLatin1String("replace")) {return returnBool(m_functionDefs.replaceFunctions.contains(var));} else if (args[1] == QLatin1String("var")) {ProValueMap::Iterator it;return returnBool(findValues(var, &it));}evalError(fL1S("defined(function, type): unexpected type [%1].").arg(args.at(1).toQStringView()));return ReturnFalse;}return returnBool(m_functionDefs.replaceFunctions.contains(var)|| m_functionDefs.testFunctions.contains(var));}
......

qmake eval(string) 函数_丘上人的博客-CSDN博客 
qmake language defineTest(testfunctionname) defineReplace(repacefunctionname) 自定义函数_丘上人的博客-CSDN博客

qmake language defined(name[, type])函数相关推荐

  1. qmake language qt 工程文件 配置文件 .pro .prl .prf .pri 词法 语法 for循环 判断语句 函数定义

    目录 词法 string 1.数据类型 2.特殊处理的内置变量 3.转义字符 关键字:包括语法关键字.特殊变量 语法 变量 变量.属性.环境变量 变量使用 全局变量作用域 函数定义和使用 判断语句和循 ...

  2. python type函数_Python type()函数

    python type函数 Python type()函数 (Python type() Function) Python has a lot of buit-in function. The typ ...

  3. linux 问题 value too large for defined data type 解决方案

    在共享文件夹下make文件的时候总是出错,错误提示为:Value too large for defined data type.在查阅了好多资料之后,发现是在mount出现了问题,如果安装了VMwa ...

  4. python class 是否存在某个变量_Python编程思想(29):使用type()函数定义类

    ----------支持作者请转发本文-----------李宁老师已经在「极客起源」 微信公众号推出<Python编程思想>电子书,囊括了Python的核心技术,以及Python的主要函 ...

  5. python函数type的用意_python之type函数

    python 的type 函数 的介绍的 下面就是此函数的参数 三个参数的意义 ''' type(class_name, base_class_tuple, attribute_dict) class ...

  6. 服务器扩充后问题总结:Value too large for defined data type

    问题描述: 服务器扩充后(900G -> 2.7T) , Linux 代码交叉编译出现问题. 出现: Value too large for defined data type (eCos产品编 ...

  7. python type函数

    阿里云大学人工智能学前小测验-Python测试 4.代码 print(type([1,2])) 输出结果为 A. <class 'list'> B. <class 'tuple'&g ...

  8. Python基础教程:type()函数-动态创建类

    type() 函数的语法格式有 2 种,分别如下: type(obj) type(name, bases, dict) 以上这 2 种语法格式,各参数的含义及功能分别是: 第一种语法格式用来查看某个变 ...

  9. no result type defined for type 'dispatch'mapped

    自己打算弄个webwork测试问题时候,遇到个脑瘫的问题,配了xwork之后,死活找不到action,报There is no result type defined for type 'dispat ...

  10. Python type 函数- Python零基础入门教程

    目录 一.type 函数简介 type 函数语法 二.type 函数实战 三.猜你喜欢 零基础 Python 学习路线推荐 : Python 学习目录 >> Python 基础入门 一.t ...

最新文章

  1. 电源完整性仿真让电路板更完美
  2. PAT甲级1023 Have Fun with Numbers:[C++题解]高精度加法和两个vector大小比较
  3. 怎样卸载外壳扩展的DLL?
  4. as3 内容自适应容器大小
  5. 选32位 64位 oracle,32位PLSQL配置为64位的Oracle和64位系统
  6. ScrollView以及TextView和对应链接
  7. MOSS 2007 User Profile 系列 索引
  8. cookie与session详解、url地址重写
  9. 一个有趣手绘风格的Python绘图库使用
  10. rpcbind.service启动失败
  11. iOS面试题(多线程篇)
  12. 网页设计_导航条_下拉菜单
  13. 通过Akka学习指数退避(Exponential Backoff)
  14. AirDisk产品S3和Q3C的区别
  15. 什么是代码?code?
  16. C/C++语言100题练习计划 98——最长最短单词
  17. Python将字符串转换为日期时间
  18. Linux命令之ntpdate、hwclock
  19. Java锁的种类和区别
  20. 插件化中Activity的加载

热门文章

  1. 本地到云端数据如何处理
  2. 我想找个这样的男朋友,要求高吗?
  3. MYSQL---查询成绩为前5名的学生
  4. 【MySQL】Select * From查询语句集合
  5. e代家园 / IT-RT508 路由器模块套装
  6. JAVA导出EXCEL格式
  7. UNet、U2Net 和U2NetP
  8. uniapp 打包上传苹果商店
  9. vmware workstation虚拟机导入vmware EXi 6.5
  10. 关于微软积分,微软商城奖励对换不了,确认奖励兑换是灰色的。解决办法,【亲测有效】【必须电脑】