我正在使用 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
但是你也可以在这里看到这个错误类型的描述:
简短的回答——正如错误所说——你不能同时使用它们。生活充满妥协,你需要选择其中一个对你来说更重要的。
解决方案是为发布版本关闭/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/