/RTC (Run-Time Error Checks)
Used to enable and disable the run-time error checks feature, in conjunction with the runtime_checks pragma.
/RTC1 /RTCc /RTCs /RTCu
Run-time error checks are a way for you to find problems in your running code; for more information, seeHow to: Use Native Run-Time Checks.
If you compile your program at the command line using any of the /RTC compiler options, any pragmaoptimize instructions in your code will silently fail. This is because run-time error checks are not valid in a release (optimized) build.
You should use /RTC for development builds; /RTC should not be used for a retail build. /RTC cannot be used with compiler optimizations (/O Options (Optimize Code)). A program image built with /RTC will be slightly larger and slightly slower than an image built with /Od (up to 5 percent slower than an /Od build).
The __MSVC_RUNTIME_CHECKS preprocessor directive will be defined when you use any /RTC option or /GZ.
To set this compiler option in the Visual Studio development environment
-
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
-
Click the C/C++ folder.
-
Click the Code Generation property page.
-
Modify one or both of the following properties: Basic Runtime Checks or Smaller Type Check.
To set this compiler option programmatically
-
See BasicRuntimeChecks and SmallerTypeCheck properties.
runtime_checks
Disables or restores the /RTC settings.
#pragma runtime_checks( "[runtime_checks]", {restore | off} )
You cannot enable a run-time check that was not enabled with a compiler option. For example, if you do not specify /RTCs, specifying #pragma runtime_checks( "s", restore) will not enable stack frame verification.
The runtime_checks pragma must appear outside a function and takes effect at the first function defined after the pragma is seen. The restore and off arguments turn options specified in the runtime_checks on or off.
The runtime_checks can be zero or more of the parameters shown in the following table.
Parameter(s) | Type of run-time check |
---|---|
s | Enables stack (frame) verification. |
c | Reports when a value is assigned to a smaller data type that results in a data loss. |
u | Reports when a variable is used before it is defined. |
These are the same letters used with the /RTC compiler option. For example:
#pragma runtime_checks( "sc", restore )
Using the runtime_checks pragma with the empty string ("") is a special form of the directive:
-
When you use the off parameter, it turns the run-time error checks, listed in the table above, off.
-
When you use the restore parameter, it resets the run-time error checks to those that you specified with the /RTC compiler option.
#pragma runtime_checks( "", off ) . . . #pragma runtime_checks( "", restore )