• <legend id='YiWb1'><style id='YiWb1'><dir id='YiWb1'><q id='YiWb1'></q></dir></style></legend>
      <tfoot id='YiWb1'></tfoot>

    1. <small id='YiWb1'></small><noframes id='YiWb1'>

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

          <bdo id='YiWb1'></bdo><ul id='YiWb1'></ul>
      1. Visual C++ 上 NOMINMAX 的可能问题

        Possible problems with NOMINMAX on Visual C++(Visual C++ 上 NOMINMAX 的可能问题)
          <bdo id='Vhegr'></bdo><ul id='Vhegr'></ul>
          <tfoot id='Vhegr'></tfoot>

          • <legend id='Vhegr'><style id='Vhegr'><dir id='Vhegr'><q id='Vhegr'></q></dir></style></legend>

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

              1. <small id='Vhegr'></small><noframes id='Vhegr'>

                  本文介绍了Visual C++ 上 NOMINMAX 的可能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我的程序中的任何其他内容之前定义 NOMINMAX 时,我会遇到什么问题?

                  What problems could I get when defining NOMINMAX before anything else in my program?

                  据我所知,这将使 没有定义 minmax 宏,从而导致许多冲突使用 STL,例如std::min()std::max()std::numeric_limits::min() 被解析.

                  As far as I know, this will make <Windows.h> not define the min and max macros such that many conflicts with the STL, e.g. std::min(), std::max(), or std::numeric_limits<T>::min() are resolved.

                  我是否正确地假设只有 Windows 特定的和遗留的代码会出现问题?几乎所有的库都不应该依赖定义为宏的 min()max() 吗?

                  Am I right in the assumption that only Windows-specific and legacy code will have problems? Almost all libraries should not depend on min() and max() defined as macros?

                  其他 Windows 标头会出现问题吗?

                  Will there be be problems with other Windows headers?

                  推荐答案

                  使用 NOMINMAX 是包含 的唯一不完全邪恶的方式.您还应该定义 UNICODESTRICT.尽管后者是现代实现默认定义的.

                  Using NOMINMAX is the only not-completely-evil way to include <windows.h>. You should also define UNICODE and STRICT. Although the latter is defined by default by modern implementations.

                  但是,您可能会遇到 Microsoft 标头的问题,例如对于 GdiPlus.我不知道任何其他公司或个人的标题有问题.

                  You can however run into problems with Microsoft’s headers, e.g. for GdiPlus. I’m not aware of problems with headers from any other companies or persons.

                  如果标头定义了一个命名空间,就像 GdiPlus 所做的那样,那么一种解决方法是为相关标头创建一个包装器,其中包含 ,并在标头的命名空间内,using namespace std;(或者using std::min;using std::max):

                  If the header defines a namespace, as GdiPlus does, then one fix is to create a wrapper for the relevant header, where you include <algorithm>, and inside the header’s namespace, using namespace std; (or alternatively using std::min; and using std::max):

                  #define NOMINMAX
                  #include <algorithm>
                  namespace Gdiplus
                  {
                    using std::min;
                    using std::max;
                  }
                  

                  请注意,这与 using namespace std; 在标题中的全局范围内有很大不同,后者永远不要.

                  Note that that is very different from a using namespace std; at global scope in header, which one should never do.

                  对于没有命名空间的情况,我不知道有什么好的解决方法,但很高兴我没有遇到这种情况,因此在实践中这个特定问题可能没有实际意义.

                  I don’t know of any good workaround for the case where there's no namespace, but happily I haven’t run into that, so in practice that particular problem is probably moot.

                  这篇关于Visual C++ 上 NOMINMAX 的可能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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++ 中生成随机数的最佳方法是什么?)

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

                          <bdo id='xSkCL'></bdo><ul id='xSkCL'></ul>
                          <legend id='xSkCL'><style id='xSkCL'><dir id='xSkCL'><q id='xSkCL'></q></dir></style></legend>
                            <tbody id='xSkCL'></tbody>
                          1. <tfoot id='xSkCL'></tfoot>

                          2. <small id='xSkCL'></small><noframes id='xSkCL'>