runtime_checks pragma

禁用或还原 /RTC 编译器选项设置。

语法

#pragma runtime_checks( " [ runtime-check-options ] ", { restore | off } )

备注

不能启用未由编译器选项启用的运行时检查。 例如,如果未在命令行上指定 /RTCs,那么指定 #pragma runtime_checks( "s", restore) 将不会启用堆栈帧验证。

runtime_checkspragma 必须在函数的外部出现,并且在显示 pragma 后定义的第一个函数处生效。 restoreoff 参数将打开或关闭 runtime_checkspragma 中指定的选项。

runtime-check-options 可以为下表中显示的零个或多个参数

runtime_checks 杂注的参数

参数 运行时检查的类型
s 启用堆栈(帧)验证。
c 报告何时向较小的数据类型赋值会导致数据丢失。
u 报告何时在定义变量前先使用了变量。

这些参数与通过 /RTC 编译器选项使用的参数相同。 例如:

#pragma runtime_checks( "sc", restore )

runtime_checkspragma 与空字符串 ("") 一起使用是指令的特殊形式:

  • 使用 off 参数时,它将关闭上表中列出的运行时错误检查。

  • 使用 restore 参数时,它会将运行时错误检查重置为使用 /RTC 编译器选项指定的检查。

#pragma runtime_checks( "", off )
/* runtime checks are off in this region */
#pragma runtime_checks( "", restore )

另请参阅

Pragma 指令以及 __pragma_Pragma 关键字