/RTC1 /RTCs /RTCc /RTCu
Run-time error checks is a way for you to find problems in your running code; see Run-Time Error Checks for a full description of this feature. The run-time error checks feature is enabled and disabled by the /RTC group of compiler options and the runtime_checks pragma.
Note If you compile your program at the command line using any of the /RTC compiler options, any pragma optimize instructions in your code will silently fail. This is because run-time error checks are not valid in a release (optimized) build.
Options | Description |
---|---|
/RTC1 | Equivalent of /RTCsu. |
/RTCs | Enables stack frame run-time error checking,
|
/RTCc | Reports when a value is assigned to a smaller data type that results in a data loss. For example, if a value of type short 0x101 is assigned to a variable of type char. |
/RTCu | Reports when a variable is used without having been initialized. For example, an instuction that generates C4701 may also generate a run-time error under /RTCu. Any instruction that generates C4700 will generate a run-time error under /RTCu.
Note that in the following code fragment: int a, *b, c; if ( 1 ) b = &a; c = a; // no run-time error with /RTCu If a variable could have been initialized, it will not be reported at run time by /RTCu. |
The following preprocessor directives will be defined when you use the compiler option(s) noted.
Preprocessor directive | Compiler option |
---|---|
__MSVC_RUNTIME_CHECKS | Any /RTC option or /GZ |
As with all compiler options, you can preface the option with either a backslash or a hyphen. For example /RTC or –RTC are equivalent.
Compiler Options | Setting Compiler Options | RTC sample