This documentation is archived and is not being maintained.

_set_purecall_handler, _set_purecall_handler_m 

Sets the handler for a pure virtual function call.

_purecall_handler _set_purecall_handler( 
      _purecall_handler function
_purecall_handler _set_purecall_handler_m( 
      _purecall_handler_m function



The function to be called when a pure virtual function is called. A _purecall_handler or _purecall_handler_m function should have a void return type.

The previous _purecall_handler. Returns NULL if there was no previous handler.

Use _set_purecall_handler if you want to catch pure virtual functions and report them to the user in a specific way or catch them for debugging purposes.

Because there is one _purecall_handler for the whole process, calling this function immediately impacts all threads. The last caller on any thread sets the handler.

There is a single _set_purecall_handler handler for all dynamically linked DLLs or executables; even if you call _set_purecall_handler your handler may be replaced by another or that you are replacing a handler set by another DLL or executable.

To restore default behavior, call _set_purecall_handler with a NULL argument.

The _set_purecall_handler_m version of the function is for mixed mode CRT.

Routine Required header Compatibility




Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For more compatibility information, see Compatibility in the Introduction.

// _set_purecall_handler.cpp
// compile with: /W1
#include <tchar.h>
#include <stdio.h>
#include <stdlib.h>

class CDerived;
class CBase
   CBase(CDerived *derived): m_pDerived(derived) {};
   virtual void function(void) = 0;

   CDerived * m_pDerived;

class CDerived : public CBase
   CDerived() : CBase(this) {};   // C4355
   virtual void function(void) {};

   m_pDerived -> function();

void myPurecallHandler(void)
   printf("In _purecall_handler.");

int _tmain(int argc, _TCHAR* argv[])
   CDerived myDerived;


In _purecall_handler.

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.