c++ - Visual Studio : Command line error D8016: '/Ox' and '/RTC' command-line options are incompatible

标签 c++ visual-studio-2012

我正在使用 Visual Studio 2012 编写 C++ 项目。我在构建项目时尝试使用 O2 或 Ox 优化。但它提示了一个错误 "cl: 命令行错误 D8016: '/Ox' 和 '/RTC' 命令行选项不兼容。"

我试图从互联网上找到解决方案,但它对我不起作用。

希望有人能帮助我。

最佳

最佳答案

首先,您的错误代码是错误的。您在发布时可能犯了错误,因为它应该是 D8016,而不是 D0816。希望您没有犯其他可能误导我们的错误...

除此之外,错误信息很清楚:

Visual Studio: Command line error D0816: '/Ox' and '/RTC' command-line options are incompatible

但是你也可以在这里看到这个错误类型的描述:

Command-Line Error D8016

简短的回答——正如错误所说——你不能同时使用它们。生活充满妥协,你需要选择其中一个对你来说更重要的。

解决方案是为发布版本关闭/RTC,仅将其用于调试版本以查找问题。查看corresponding documentation ,也可以从上面的第一个链接获得更多详细信息:

Run-time error checks are a way for you to find problems in your running code; for more information, see How to: Use Native Run-Time Checks.

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.

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).

关于c++ - Visual Studio : Command line error D8016: '/Ox' and '/RTC' command-line options are incompatible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23179136/

相关文章:

c++ - 从exe和dll访问静态库中的外部变量

c++ - 如何通过引用增强迭代用户定义对象类型集 (STL) 的数组元素?

c# - 从本地数据库更改为托管在服务器上的 SQL Server

c# - 禁用特定控件的设计模式

c++ - 在 Visual Studio C++ 2012 上检测缓冲区溢出的静态分析

c++ - MS Visual Studio 2012 Update 2 是否编译 C++11 原始字符串文字?

c# - 如何避免闪烁按钮WPF

c++ - 使用新线程复制互斥锁所有权

c++ - 错误 : clBuildProgram(CL_BUILD_PROGRAM_FAILURE)

c++ - 对 int 类型和无符号整数的值应用模运算