<legend id='hsxPI'><style id='hsxPI'><dir id='hsxPI'><q id='hsxPI'></q></dir></style></legend>
<i id='hsxPI'><tr id='hsxPI'><dt id='hsxPI'><q id='hsxPI'><span id='hsxPI'><b id='hsxPI'><form id='hsxPI'><ins id='hsxPI'></ins><ul id='hsxPI'></ul><sub id='hsxPI'></sub></form><legend id='hsxPI'></legend><bdo id='hsxPI'><pre id='hsxPI'><center id='hsxPI'></center></pre></bdo></b><th id='hsxPI'></th></span></q></dt></tr></i><div id='hsxPI'><tfoot id='hsxPI'></tfoot><dl id='hsxPI'><fieldset id='hsxPI'></fieldset></dl></div>
      <tfoot id='hsxPI'></tfoot>
    1. <small id='hsxPI'></small><noframes id='hsxPI'>

        <bdo id='hsxPI'></bdo><ul id='hsxPI'></ul>

        /Ox 和/O2 编译器选项之间有什么区别?

        What is the difference between the /Ox and /O2 compiler options?(/Ox 和/O2 编译器选项之间有什么区别?)
            <tbody id='wNQ7w'></tbody>
            <legend id='wNQ7w'><style id='wNQ7w'><dir id='wNQ7w'><q id='wNQ7w'></q></dir></style></legend>

                <small id='wNQ7w'></small><noframes id='wNQ7w'>

              • <i id='wNQ7w'><tr id='wNQ7w'><dt id='wNQ7w'><q id='wNQ7w'><span id='wNQ7w'><b id='wNQ7w'><form id='wNQ7w'><ins id='wNQ7w'></ins><ul id='wNQ7w'></ul><sub id='wNQ7w'></sub></form><legend id='wNQ7w'></legend><bdo id='wNQ7w'><pre id='wNQ7w'><center id='wNQ7w'></center></pre></bdo></b><th id='wNQ7w'></th></span></q></dt></tr></i><div id='wNQ7w'><tfoot id='wNQ7w'></tfoot><dl id='wNQ7w'><fieldset id='wNQ7w'></fieldset></dl></div>
                • <bdo id='wNQ7w'></bdo><ul id='wNQ7w'></ul>
                  <tfoot id='wNQ7w'></tfoot>
                  本文介绍了/Ox 和/O2 编译器选项之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Microsoft 的 C++ 编译器(cl.exe,包含在 Visual Studio 中)提供 几个优化开关.它们中的大多数之间的区别似乎不言自明,但我不清楚 /O2(优化代码以获得最大速度)和 /Ox(选择完全优化").

                  Microsoft's C++ compiler (cl.exe, as included with Visual Studio) offers several optimization switches. The difference between most of them seems self-explanatory, but it's not clear to me what the difference is between /O2 (which optimizes code for maximum speed) and /Ox (which selects "full optimization").

                  我已经尝试阅读 文档 的 /Ox 选项,它似乎确认此开关还可以优化最大速度,而不是大小:

                  I've tried reading the documentation for the /Ox option, and it seems to confirm that this switch also enables optimizations for maximum speed, rather than size:

                  /Ox 编译器选项生成的代码有利于执行速度而不是较小的尺寸.

                  The /Ox compiler option produces code that favors execution speed over smaller size.

                  但特别是,备注"部分下的以下声明引起了我的注意:

                  But in particular, the following statement under the "Remarks" section caught my eye:

                  通常,指定/O2(最大化速度)而不是/Ox.

                  In general, specify /O2 (Maximize Speed) instead of /Ox.

                  所以我的问题是,为什么人们普遍偏爱 /O2 而不是 /Ox? 后一个选项是否启用了已知的特定优化导致不可预见的错误或其他意外行为?是否只是要获得的优化量不值得额外的编译时间?或者这只是一个完全没有意义的推荐",因为 /O2 是 VS 中的默认选项?

                  So my question is, why should one generally favor /O2 over /Ox? Does the latter option enable a particular optimization known to cause unforeseen bugs or otherwise unexpected behavior? Is it simply that the amount of optimization to be gained is not worth the additional compile time? Or is this just a completely meaningless "recommendation" resulting from the fact that /O2 is the default option in VS?

                  推荐答案

                  Asha 的回答 引用了一篇关于 Visual Studio 2005 的博客文章,而且已经过时了.

                  Asha's answer cites a blog post about Visual Studio 2005, and is rather out of date.

                  最新版本的文档可在此处获得:

                  The latest version of the documentation is available here:

                  • /Ox:https://msdn.microsoft.com/en-us/library/59a3b321.aspx
                  • /O2:https://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx

                  根据那些:

                  • /Ox/Og/Oi/Ot/Oy/Ob2
                  • /O2 →相同,但进一步添加 /Gs/GF/Gy

                  • /Ox/Og /Oi /Ot /Oy /Ob2
                  • /O2 → the same, but further adds /Gs /GF /Gy

                  • /GF 消除重复字符串
                  • /Gy 执行函数级链接

                  您可能还对 /GS- 感兴趣,它会关闭堆栈周围的安全检查,这可能会严重影响性能(请参阅 /GS 的 MS 文档).

                  You may additionally be interested in /GS- which turns off security checks around the stack, which can be a significant performance hit (see the MS docs for /GS).

                  您应该一如既往地对您的特定应用程序进行基准测试.

                  You should benchmark your specific application, as ever.

                  这篇关于/Ox 和/O2 编译器选项之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Consistent pseudo-random numbers across platforms(跨平台一致的伪随机数)
                  Vary range of uniform_int_distribution(改变uniform_int_distribution的范围)
                  What is a seed in terms of generating a random number?(就生成随机数而言,种子是什么?)
                  Is 1.0 a valid output from std::generate_canonical?(1.0 是 std::generate_canonical 的有效输出吗?)
                  Getting big random numbers in C/C++(在 C/C++ 中获取大随机数)
                  What is the best way to generate random numbers in C++?(在 C++ 中生成随机数的最佳方法是什么?)

                      <legend id='ukbKD'><style id='ukbKD'><dir id='ukbKD'><q id='ukbKD'></q></dir></style></legend>

                      <tfoot id='ukbKD'></tfoot>
                    • <small id='ukbKD'></small><noframes id='ukbKD'>

                          <bdo id='ukbKD'></bdo><ul id='ukbKD'></ul>
                            <tbody id='ukbKD'></tbody>
                          1. <i id='ukbKD'><tr id='ukbKD'><dt id='ukbKD'><q id='ukbKD'><span id='ukbKD'><b id='ukbKD'><form id='ukbKD'><ins id='ukbKD'></ins><ul id='ukbKD'></ul><sub id='ukbKD'></sub></form><legend id='ukbKD'></legend><bdo id='ukbKD'><pre id='ukbKD'><center id='ukbKD'></center></pre></bdo></b><th id='ukbKD'></th></span></q></dt></tr></i><div id='ukbKD'><tfoot id='ukbKD'></tfoot><dl id='ukbKD'><fieldset id='ukbKD'></fieldset></dl></div>