This documentation is archived and is not being maintained.

Using Run-Time Checks Without the C Run-Time Library

If you link your program without the C run-time library (using /NODEFAULTLIB) and want to use run-time checks, you must link with RunTmChk.lib.

_RTC_Initialize initializes your program for run-time checks. If you do not link with the C run-time library, you must check to see whether your program is compiled with run-time error checks before calling _RTC_Initialize:

#ifdef __MSVC_RUNTIME_CHECKS
   _RTC_Initialize();
#endif

If you do not link with the C run-time library, you must also define a function called _CRT_RTC_INIT. _CRT_RTC_INIT installs your user-defined function as the default error reporting function:

// C version
_RTC_error_fn __cdecl _CRT_RTC_INIT(void *res0, void **res1, int res2, 
int res3, int res4);
{
   return &MyErrorFunc; // set the error handler
}

// C++ version
extern "C" _RTC_error_fn __cdecl _CRT_RTC_INIT(void *res0, void **res1, 
int res2, int res3, int res4);
{
   return &MyErrorFunc; // set the error handler
}

After you have installed the default error reporting function, you can install additional error reporting functions with _RTC_SetErrorFunc. For more information, see _RTC_SetErrorFunc.

See Also

Run-Time Error Checks

Show: