【问题标题】:Why Qt .pro file gives error for a platform, even when it is not selected or mentioned?为什么 Qt .pro 文件会为平台提供错误,即使没有选择或提及它?
【发布时间】:2018-03-01 13:34:49
【问题描述】:

在我的 Qt .pro 文件中,以下给出了 Windows 操作系统的编译错误:

!win32
{
  QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-missing-field-initializers -Wimplicit-fallthrough=0
}

根据qmake tutorial,Windows平台应该绕过上面的块。然而,即使对 Windows 进行完整性检查,它也会出现错误,即使它不适用。

还有其他类似的例子。
如何修复此类错误?

【问题讨论】:

  • 嗯,错误是什么?

标签: c++ windows qt compiler-errors qmake


【解决方案1】:

在这种情况下,由于 Qt QMake 语法而出现问题。从这个链接QMake Advanced Usage

作用域由一个条件组成,后跟一个同一行的左大括号、一系列命令和定义,以及一个新行的右大括号。左大括号必须与条件写在同一行。范围可以连接起来以包含多个条件;

语法:

<condition> {
  0<command or definition>
...
}

.pro 文件更改:

!win32 {
QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-missing-field-initializers -Wimplicit-fallthrough=0
}  # compiles fine

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-12
    • 2019-10-11
    • 1970-01-01
    相关资源
    最近更新 更多