Udostępnij za pośrednictwem


How to: Use Native Run-Time Checks

This topic applies to:

Edition

Visual Basic

C#

C++

Web Developer

Express

Topic does not apply Topic does not apply

Native only

Topic does not apply

Standard

Topic does not apply Topic does not apply

Native only

Topic does not apply

Pro and Team

Topic does not apply Topic does not apply

Native only

Topic does not apply

Table legend:

Topic applies

Applies

Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default.

In Visual C++, you can use native runtime_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.

If you 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 that has 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 more information, see Exception Handling (Debugging).

The following procedures describe how to enable native run-time checks in a debug build, and how to modify native run-time check behavior.

Other topics in this section provide information about:

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.

See Also

Tasks

RTC Sample: Run-Time Error Checks

Reference

runtime_checks

Run-Time Error Checking

Other Resources

Debugging in Visual Studio