Share via


Native Run-Time Checks Customization

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

When you compile with /RTC (run-time checks) or use the runtime_checks pragma, the C run-time library provides native run-time checks. In some cases, you might want to customize run-time checking:

  • To route run-time check messages to a file or destination other than the default.

  • To specify an output destination for run-time check messages under a third-party debugger.

  • To report run-time check messages from a program compiled with a release version of the C run-time library. Release versions of the library do not use _CrtDbgReportW to report run-time errors. Instead, they display an Assert dialog box for each run-time error.

    To customize run-time error checking, you can:

  • Write a run-time error reporting function. For more information, see How to: Write a Run-Time Error Reporting Function.

  • Customize the error message destination.

  • Query for information about run-time check errors.

Customize the Error Message Destination

If you use _CrtDbgReportW to report errors, you can use _CrtSetReportMode to specify the destination of error messages.

If you use a custom reporting function, use _RTC_SetErrorType to associate an error with a report type.

Query for Information About Run-Time Checks

_RTC_NumErrors returns the number of error types detected by run-time error checks. To get a brief description of each error, you can loop from 0 to the return value of _RTC_NumErrors, passing the iteration value to _RTC_GetErrDesc on each loop. For more information, see _RTC_NumErrors and _RTC_GetErrDesc.

See also