This documentation is archived and is not being maintained.


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.


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

void func1(void) {

__declspec(deprecated) void func1(int) {

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

The following sample shows how to deprecate a class:

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

int main()
   X x;   // C4996

END Microsoft Specific

See Also

__declspec | C++ Keywords