Obsolete Members for <QtCompilerDetection>
<QtCompilerDetection> 类的以下成员已被废弃。提供这些成员是为了确保旧源代码能够继续运行。我们强烈建议不要在新代码中使用它们。
宏
(deprecated) | Q_CC_INTEL |
(deprecated in 6.4) | Q_DECL_CONSTEXPR |
(deprecated in 5.15) | Q_DECL_FINAL |
(deprecated in 6.4) | Q_DECL_NOEXCEPT |
(deprecated in 6.4) | Q_DECL_NOEXCEPT_EXPR(x) |
(deprecated in 6.4) | Q_DECL_NOTHROW |
(deprecated in 5.15) | Q_DECL_OVERRIDE |
(deprecated in 6.4) | Q_DECL_RELAXED_CONSTEXPR |
宏文档
[deprecated] Q_CC_INTEL
此宏已弃用。我们强烈建议不要在新代码中使用它。
如果应用程序是使用旧版 Intel C++ 编译器(适用于 Linux、macOS 或 Windows)编译的,则会定义此宏。新的 oneAPI C++ 编译器只是 Clang 的一个构建版本,因此不会定义此宏。
另请参阅 Q_CC_CLANG 。
[deprecated in 6.4] Q_DECL_CONSTEXPR
自 6.4 版本起,此宏已被废弃。我们强烈建议不要在新代码中使用它。
请改用constexpr 关键字。
该宏可用于声明应在编译时构造的变量,或可在编译时计算的内联函数。
另请参阅 Q_DECL_RELAXED_CONSTEXPR 和Q_DECL_CONSTEXPR_DTOR 。
[deprecated in 5.15] Q_DECL_FINAL
自 5.15 版本起,此宏已被废弃。我们强烈建议不要在新代码中使用它。
该宏可用于将重写的虚函数或类声明为“final”,其语义与 Java 一致。这样一来,进一步派生的类将无法再重写该虚函数,或无法再继承该类。
它展开为“final”。
该宏应置于函数末尾,通常在const 之后(如有):
// more-derived classes no longer permitted to override this:
virtual void final_func() final;对于类,若存在: ,则应将其置于类定义中 之前:
class SomeClass final { // cannot be derived from
// ...
};另请参阅 Q_DECL_OVERRIDE 。
[deprecated in 6.4] Q_DECL_NOEXCEPT
自 6.4 版本起,该宏已被废弃。我们强烈建议不要在新代码中使用它。
请改用noexcept 关键字。
该宏将函数标记为“绝不抛出异常”。如果该函数最终仍抛出异常,则行为已定义:将调用 std::terminate()。
另请参阅 Q_DECL_NOTHROW 和Q_DECL_NOEXCEPT_EXPR()。
[deprecated in 6.4] Q_DECL_NOEXCEPT_EXPR(x)
自 6.4 版本起,此宏已被废弃。我们强烈建议不要在新代码中使用它。
请改用noexcept 关键字。
如果 `x ` 的值为 `true`,则该宏会将函数标记为不抛出异常。如果函数仍抛出异常,其行为是明确定义的:将调用 `std::terminate()`。
另请参见 Q_DECL_NOTHROW 和Q_DECL_NOEXCEPT 。
[deprecated in 6.4] Q_DECL_NOTHROW
自 6.4 版本起,该宏已被废弃。我们强烈建议不要在新代码中使用它。
请改用noexcept 关键字。
该宏将函数标记为在任何情况下都不会抛出异常。如果函数仍抛出异常,则行为未定义。
另请参阅 ` Q_DECL_NOEXCEPT ` 和 `Q_DECL_NOEXCEPT_EXPR()`。
[deprecated in 5.15] Q_DECL_OVERRIDE
自 5.15 起,该宏已被废弃。我们强烈建议不要在新代码中使用它。
该宏可用于声明一个重写虚拟函数。使用此标记将使编译器在重写虚拟函数实际上并未重写任何内容时生成错误。
它展开为“override”。
该宏应置于函数末尾,通常位于const 之后(如有):
// generate error if this doesn't actually override anything:
virtual void override_func() override;另请参阅 ` Q_DECL_FINAL`。
[deprecated in 6.4] Q_DECL_RELAXED_CONSTEXPR
自 6.4 版本起,该宏已被弃用。我们强烈建议不要在新代码中使用它。
请改用constexpr 关键字。
该宏可用于声明一个内联函数,该函数可根据 C++14 的宽松规则在编译时进行计算。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.