gpt4 book ai didi

c++ - `clang-check` 是否未能兑现 `-isystem` ?

转载 作者:搜寻专家 更新时间:2023-10-31 02:21:39 26 4
gpt4 key购买 nike

对于 Clang 和 GCC,-isystem 标志添加了一个“系统”包含路径,这会导致编译器发出与这些 header 中的代码相关的警告.

但是,在我的代码上运行 clang-check 时,我看到了以下警告:

In file included from <myfile>.cpp:1:
In file included from <Qt-path>/gcc_64/include/QtCore/QCoreApplication:1:
In file included from <Qt-path>/gcc_64/include/QtCore/qcoreapplication.h:40:
<Qt-path>/gcc_64/include/QtCore/qobject.h:235:16: warning: Potential memory leak
return connectImpl(sender, reinterpret_cast<void **>(&signal),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

...所以看起来 clang-check 不对待 -isystem 包含路径不同于 -I 包含路径。我是否滥用了该工具或误解了输出(即,这实际上是我代码中的潜在错误)?在运行 clang-check 时,是否有另一种方法可以显式忽略来自 Qt header 的错误?

最佳答案

这是因为除了基本的 Qt 包含目录之外,您还必须通过-“isystem”包含“QtCore”目录。这是因为 Clang 找到了一个更具体的包含(QT - 也是模块)并使用它。查看Clang Manual for -isystem 有关包含如何工作的信息。

实际上您想执行以下操作:

contains(QT,"core") {
QMAKE_CXXFLAGS *= $$join(QMAKE_INCDIR_QT, " -isystem", "-isystem", "/QtCore")
}

并对所有标准 Qt 模块(Designer、Gui、Help、Network 等)重复此操作。

关于c++ - `clang-check` 是否未能兑现 `-isystem` ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31172832/

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