Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.