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 error checks, you must link with RunTmChk.lib.

_RTC_InitBase initializes your program for run-time error 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_InitBase:

#ifdef __MSVC_RUNTIME_CHECKS
   _RTC_InitBase();
#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.