有什么方法可以禁用特定代码行的编译器优化?

有什么方法可以禁用 Visual Studio 中特定代码行的编译器优化?

解决方案

没有.

仅在逐个函数的基础上使用 优化编译指示:

 #pragma optimize("[优化列表]", {on | off} )

<块引用>

optimize pragma 必须出现在函数之外并在之后定义的第一个函数看到 pragma.开和关arguments 中指定的选项打开或关闭优化列表.

用法:

#pragma optimize("", off)...#pragma 优化(",开)

is there any way to disable compiler optimisation for a specific line of code in Visual studio?

解决方案

No.

Only on a function-by-function basis using the optimize pragma:

 #pragma optimize( "[optimization-list]", {on | off} )

The optimize pragma must appear outside a function and takes effect at the first function defined after the pragma is seen. The on and off arguments turn options specified in the optimization-list on or off.

usage:

#pragma optimize( "", off )
.
.
.
#pragma optimize( "", on ) 

相关文章