Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/131.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C+中标记已过时或不推荐的类/方法+; 有没有一种方法在C++中标记为过时的方法?< /P>_C++_Compiler Construction_Attributes - Fatal编程技术网

在C+中标记已过时或不推荐的类/方法+; 有没有一种方法在C++中标记为过时的方法?< /P>

在C+中标记已过时或不推荐的类/方法+; 有没有一种方法在C++中标记为过时的方法?< /P>,c++,compiler-construction,attributes,C++,Compiler Construction,Attributes,用c#你可以写: [Obsolete("You shouldn't use this method anymore.")] void foo() {} 如果有必要,我会使用GNU工具链/EclipseCDT。仅使用依赖于编译器的pragmas:查找 我不知道你使用的是C++版本,但是微软的Visual C++有一个版本。可能您的版本也有类似的功能。最简单的方法是使用#define DEPRECATED。在GCC上,它扩展到第14属性( >,在VisualC++中扩展到,并且在没有Selima

用c#你可以写:

[Obsolete("You shouldn't use this method anymore.")]
void foo() {}

如果有必要,我会使用GNU工具链/EclipseCDT。

仅使用依赖于编译器的pragmas:查找


我不知道你使用的是C++版本,但是微软的Visual C++有一个版本。可能您的版本也有类似的功能。

最简单的方法是使用
#define DEPRECATED
。在GCC上,它扩展到<代码>第14属性(<(弃权)> <代码> >,在VisualC++中扩展到,并且在没有Selimar的编译器上扩展到没有任何东西。

< P> C++(或以后)现在提供了这个特性:


这显示了如何弃用函数。整个类也可以被弃用吗?这个问题简单地暗示了这一点,我通过谷歌找到了这个问题。很高兴在这里捕捉到这一点。您提供的链接引用了C++14支持。@nChadle已修复。:)
 int old_fn () __attribute__ ((deprecated));
[[deprecated]] void F();
[[deprecated("reason")]] void G();
class [[deprecated]] H { /*...*/ };