Using Native Run-Time Checks
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Using Native Run-Time Checks

In Visual C++, you can use native run-time checks to catch common run-time errors such as:

  • Stack pointer corruption.
  • Overruns of local arrays.
  • Stack corruption.
  • Dependencies on uninitialized local variables.
  • Loss of data on an assignment to a shorter variable.

To enable native run-time checks in a debug build

  • Use the /RTC option and link with the debug version of a C run-time library (/MDd, for example).

To modify native run-time check behavior

  • Use the runtime_checks pragma.

You cannot use /RTC with an optimized (/O) build. A compiler error results. If you use a runtime_checks pragma in an optimized build, the pragma has no effect.

When you debug a program with run-time checks enabled, the default action is for the program to stop and break to the debugger when a run-time error occurs. You can change this default behavior for any run-time check. For details, see Changing How the Debugger Handles Exceptions.

Other topics in this section provide information on:

See Also

Debugging Your Program | runtime_checks | Run-Time Error Checks Function Reference | RTC sample

© 2015 Microsoft