Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
deprecated

deprecated

Microsoft Specific

With the exceptions noted below, the deprecated declaration offers the same functionality as the deprecated pragma:

  • The deprecated declaration lets you specify particular forms of function overloads as deprecated, whereas the pragma form applies to all overloaded forms of a function name.
  • Macros can only be marked as deprecated with the deprecated pragma.

If the compiler encounters the use of a deprecated identifier, a C4996 warning is thrown.

Example

// deprecated.cpp
// compile with: /W1
#include <stdio.h>

void func1(void) {
}

__declspec(deprecated) void func1(int) {
}

int main() {
   func1();
   func1(1);   // C4996
}

The following sample shows how to deprecate a class:

// deprecate_class.cpp
// compile with: /W1
class __declspec(deprecated) X
{
public:
   void f(){}
};

int main()
{
   X x;   // C4996
}

END Microsoft Specific

See Also

__declspec | C++ Keywords

Show:
© 2015 Microsoft