☰
  • 首页
  • 规则分类
  • 项目介绍
search
•••

不应使用具有 deprecated 属性的函数、对象或类型

6.12.10 ID_usingDeprecatedName
目录 › next › previous

deprecated 属性用于标记已过时的函数、对象或类型,具有该属性的函数、对象或类型不应再被使用。

示例:

[[deprecated]] int fun();   // C++14 attribute

int main() {
    return fun();   // Non-compliant
}

在 C 代码以及遵循 C++14 之前标准的 C++ 代码中可使用相关编译器扩展属性,如:

#ifdef _MSC_VER
__declspec(deprecated) int fun();   // MSVC attribute
#elif defined __GNUC__
__attribute__((deprecated)) int fun();   // GCC attribute
#endif

具有相同属性的函数、对象或类型均受本规则约束。

依据

ISO/IEC 14882:2014 7.6.5 ISO/IEC 14882:2017 10.6.4
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.