Checks for certain conditions at run time.

Syntax

Linux and macOS:

-check=keyword[, keyword...]

Windows:

/check:keyword[, keyword...]

Arguments

keyword

Specifies the conditions to check. Possible values are:

[no]conversions

Determines whether checking occurs for converting to smaller types. Keyword conversions enables this checking.

[no]stack

Determines whether checking occurs on the stack frame. Keyword stack enables this checking. If stack is specified, the stack is checked for buffer overruns and buffer underruns. This option also enforces local variables initialization and stack pointer verification.

[no]uninit

Determines whether checking occurs for uninitialized variables. Keyword uninit enables this checking. If a variable is read before it is written, a run-time error routine will be called.

Run-time checking of undefined variables is only implemented on local, scalar variables. It is not implemented on dynamically allocated variables, extern variables or static variables. It is not implemented on structs, classes, unions or arrays.

Default

noconversions
nostack
nouninit

No checking is performed for the above run-time conditions.

Description

This option checks for certain conditions at run time.

On Windows* systems, this option disables any default or specified optimizations and applies the /Od level of optimization. If you specified optimizations, the compiler emits warning diagnostics for the disabled optimizations.

On Linux* and macOS* systems, this option may disable some optimizations.

Note

This option requires library support. Depending on the platform, the required library is either in your operating system run-time environment or in your compiler package.

IDE Equivalent

Visual Studio: None

Eclipse: Runtime > Check Stack Frame (-check=stack)

Runtime > Check Type Conversions (-check=conversions)

Runtime > Check Uninitialized Variables (-check=uninit)

Xcode: Runtime > Check Stack Frame (-check=stack)

Runtime > Check Type Conversions (-check=conversions)

Runtime > Check Uninitialized Variables (-check=uninit)

Alternate Options

check:conversions

Linux and macOS*: None

Windows: /RTCc

check:stack

Linux and macOS*: None

Windows: /RTCs

check:uninit

Linux and macOS*: None

Windows: /RTCu

有关编译器优化的更完整信息,请参阅优化通知