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

    • <bdo id='ruH9e'></bdo><ul id='ruH9e'></ul>

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

        <legend id='ruH9e'><style id='ruH9e'><dir id='ruH9e'><q id='ruH9e'></q></dir></style></legend>
        <tfoot id='ruH9e'></tfoot>

        Visual C++ 上 NOMINMAX 的可能问题

        时间:2023-10-06
        <tfoot id='Wuywt'></tfoot>
        <legend id='Wuywt'><style id='Wuywt'><dir id='Wuywt'><q id='Wuywt'></q></dir></style></legend>
        • <bdo id='Wuywt'></bdo><ul id='Wuywt'></ul>
              • <small id='Wuywt'></small><noframes id='Wuywt'>

                    <tbody id='Wuywt'></tbody>
                  <i id='Wuywt'><tr id='Wuywt'><dt id='Wuywt'><q id='Wuywt'><span id='Wuywt'><b id='Wuywt'><form id='Wuywt'><ins id='Wuywt'></ins><ul id='Wuywt'></ul><sub id='Wuywt'></sub></form><legend id='Wuywt'></legend><bdo id='Wuywt'><pre id='Wuywt'><center id='Wuywt'></center></pre></bdo></b><th id='Wuywt'></th></span></q></dt></tr></i><div id='Wuywt'><tfoot id='Wuywt'></tfoot><dl id='Wuywt'><fieldset id='Wuywt'></fieldset></dl></div>
                  本文介绍了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 的可能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:致命错误:“无目标架构"在 Visual Studio 中 下一篇:打印 C++ 结构中所有字段的值

                  相关文章

                  最新文章

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

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