【问题标题】:What preprocessor can I used to detect if QT is used to build my codes我可以使用什么预处理器来检测 QT 是否用于构建我的代码
【发布时间】:2015-08-30 15:41:45
【问题描述】:

我正在用 C 语言编写一个库项目,它可以使用或不使用 QT 构建。是否有任何预处理器指令(不需要额外的标头)可以用来区分 C 代码中是否使用了 QT?

我想做类似的事情:

#ifdef I_AM_QT
// some qt specific codes
#else
// some codes for other environments
#endif

谢谢。

【问题讨论】:

  • 你不能设置你自己的定义来表明你是用还是不用Qt来构建的?
  • 你可以看看these

标签: qt preprocessor c-preprocessor


【解决方案1】:
#ifdef QT_CORE_LIB
// some qt specific codes
#else
// some codes for other environments
#endif

【讨论】:

  • 问题状态为... no extra headers are required... 。你可以使用QT_CORE_LIBdefine 而不包含Qt 标头吗?
  • @vahancho,是的。至少,对于 Qt 5.12.4,我看到使用 CMake 构建项目时使用 -DQT_CORE_LIB 调用编译器,因此它是一个可用于所有源文件的全局宏定义。
猜你喜欢
  • 2011-02-09
  • 1970-01-01
  • 1970-01-01
  • 2021-12-15
  • 2014-07-19
  • 2015-12-18
  • 1970-01-01
相关资源
最近更新 更多