This documentation is archived and is not being maintained.


Designates a function as the handler for reporting run-time error checks (RTC).

_RTC_error_fn _RTC_SetErrorFunc(
   _RTC_error_fn function 


The address of the function that will handle run-time error checks.

Return Value

The previously-defined error function. If there is no previously-defined function, returns NULL.


Make sure that the address you pass to _RTC_SetErrorFunc is that of a valid error handling function.

If an error has been assigned a type of –1 with _RTC_SetErrorType, the error handler function will not be called.

Before you can call this function, you must first call one of the run-time error check initialization functions; see Using Run-Time Checks without the C Run-Time Library

_RTC_error_fn is defined as follows:

typedef int (__cdecl *_RTC_error_fn)(int errorType, const char *filename, int linenumber, const char *moduleName, const char *format, ...);


The type of error specified by _RTC_SetErrorType.
The source file where the failure occurred or null if no debug information is available.
The line in filename where the failure occurred or 0 if no debug information is available.
The DLL or EXE name where failure occurred.
printf style string to display an error message, using the remaining parameters. The first argument of the VA_ARGLIST is the RTC Error number that occurred.

See Customizing CRT Run-Time Error Checking for an example of using _RTC_error_fn.


Routine Required header Compatibility
_RTC_SetErrorFunc <rtcapi.h> Win 98, Win Me, Win NT, Win 2000, Win XP

See Compatibility for additional information.


All versions of the C run-time libraries.

See Also

_CrtDbgReport | Run-Time Error Checks Function Reference | RTC sample | Run-Time Routines and .NET Framework Equivalents