deprecated
Go Up to Keywords, Alphabetical Listing Index
Contents
Syntax
<entity declaration> [[deprecated]]
or
<entity declaration> [[deprecated("message")]]
Description
Use the deprecated attribute to flag your user-defined constructs as deprecated. A deprecated construct is old or outdated, can be replaced by a better substitute, is not supposed to be used anymore, or might not be supported in the future.
If a deprecated construct is found, a W8111 Accessing deprecated entity %s (C++) warning is thrown. The warning is thrown for any type of deprecated entity, including variables of a deprecated type.
The second form of the syntax allows users to output a message in the warning. The message usually recommends the newer construct that should be used.
The warning message is issued if the entity declared as deprecated is used in code, otherwise not.
The constructs that support the deprecated attribute are as follows:
Enums
enum myEnum [[deprecated]] { e0, e1, e2 };
myEnum e = e1; //W8111 Accessing deprecated entity 'myEnum'
Global Functions/Variables
int x [[deprecated]];
void myFunc(int, int) [[deprecated("use myFunc(int,double) instead")]] {
}
void myFunc(int, double){
}
//...
myFunc(3,3); //W8111 Accessing deprecated entity 'myFunc(int,int)' use myFunc(int,double) instead
Classes/Structs
class A [[deprecated]] {
} a0; //Warning
struct B [[deprecated]] {
} b0; //Warning
class C : A{
}
//...
C c0; //W8111 Accessing deprecated entity 'A'
Methods and Fields
class A{
public:
int m_x [[deprecated]];
int m_y [[deprecated]];
A(int x, double y){}
A(int x, int y) [[deprecated("use the A(int,double) constructor")]]{} //W8111 Accessing deprecated entity 'A::A(int,int)' use the A(int,double) constructor
} a0(5,6);
//...
A a1(5,1.0);//No warning
a1.m_x=5; //W8111 Accessing deprecated entity 'A::m_x'
Template Classes
template <class T> class A {
public:
template <class T> class B [[deprecated]] {};
};
//...
A<int>::B<double> a0; //W8111 Accessing deprecated entity 'A<int>::B<double>'
Example
In SysUtils.hpp:
class PASCALIMPLEMENTATION EStackOverflow [[deprecated]] : public EExternal
Portability
POSIX | Win32 | Win64 | ANSI C | ANSI C++ | |
---|---|---|---|---|---|
deprecated |
+ |