| title | deprecated (C/C++) | Microsoft Docs | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ms.custom | ||||||||||||||
| ms.date | 11/04/2016 | |||||||||||||
| ms.reviewer | ||||||||||||||
| ms.suite | ||||||||||||||
| ms.technology |
|
|||||||||||||
| ms.tgt_pltfrm | ||||||||||||||
| ms.topic | article | |||||||||||||
| f1_keywords |
|
|||||||||||||
| dev_langs |
|
|||||||||||||
| helpviewer_keywords |
|
|||||||||||||
| ms.assetid | 9c046f12-7875-499a-8d5d-12f8642fed2d | |||||||||||||
| caps.latest.revision | 7 | |||||||||||||
| author | corob-msft | |||||||||||||
| ms.author | corob | |||||||||||||
| manager | ghogen | |||||||||||||
| translation.priority.ht |
|
The deprecated pragma lets you indicate that a function, type, or any other identifier may no longer be supported in a future release or should no longer be used.
Note
For information about the C++14 [[deprecated]] attribute, and guidance on when to use that attribute vs the Microsoft declspec or pragma, see C++ Standard Attributes attribute.
#pragma deprecated( identifier1 [,identifier2, ...] )
When the compiler encounters a deprecated symbol, it issues C4995.
You can deprecate macro names. Place the macro name in quotes or else macro expansion will occur.
The deprecated __declspec modifier allows you to specify deprecated status for particular forms of overloaded functions.
// pragma_directive_deprecated.cpp
// compile with: /W3
#include <stdio.h>
void func1(void) {
}
void func2(void) {
}
int main() {
func1();
func2();
#pragma deprecated(func1, func2)
func1(); // C4995
func2(); // C4995
}
The following sample shows how to deprecate a class:
// pragma_directive_deprecated2.cpp
// compile with: /W3
#pragma deprecated(X)
class X { // C4995
public:
void f(){}
};
int main() {
X x; // C4995
}