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

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

  • <tfoot id='WcqQY'></tfoot>
    1. <legend id='WcqQY'><style id='WcqQY'><dir id='WcqQY'><q id='WcqQY'></q></dir></style></legend>
        <bdo id='WcqQY'></bdo><ul id='WcqQY'></ul>

      1. 无法理解 LARGE_INTEGER 结构

        can#39;t make sense of LARGE_INTEGER struct(无法理解 LARGE_INTEGER 结构)

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

          1. <tfoot id='LQqrC'></tfoot>
            • <bdo id='LQqrC'></bdo><ul id='LQqrC'></ul>
                <legend id='LQqrC'><style id='LQqrC'><dir id='LQqrC'><q id='LQqrC'></q></dir></style></legend>

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

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

                  问题描述

                  使用 C++ 和一些 Winapi 的东西,我遇到了这个家伙:

                  With C++ and some Winapi things, I encountered this guy:

                  #if defined(MIDL_PASS)
                  typedef struct _LARGE_INTEGER {
                  #else // MIDL_PASS
                  typedef union _LARGE_INTEGER {
                      struct {
                          DWORD LowPart;
                          LONG HighPart;
                      };
                      struct {
                          DWORD LowPart;
                          LONG HighPart;
                      } u;
                  #endif //MIDL_PASS
                      LONGLONG QuadPart;
                  } LARGE_INTEGER;
                  

                  所以,在我看来,取决于 MIDL_PASS 是否设置,这要么是一个非常紧凑的结构,其中只有一个 LONGLONG,要么更有趣的是,这变成了一个联合.

                  So, the way I see it, depending on MIDL_PASS being set or not, this is either a very compact struct with only a LONGLONG in it, or the much more interesting case, this becomes a union.

                  如果这是一个联合,对我来说仍然有意义,有两种访问可能性,一次是 LONGLONG 在一个块中,一次是具有 Low 和 Highpart 的结构.到目前为止一切顺利.

                  In case this is a union, it still makes sense to me, to have two possibilites of access, once the LONGLONG in one chunk, and once the struct with Low and Highpart. So far so good.

                  但是我无法理解结构被声明两次的事实,同样的.似乎他们都是匿名的,但后一个可以通过u"获得.

                  But I cannot make any sense out of the fact that the struct is declared twice, identically. It seems they are both anonymous, but the latter one is available via "u".

                  现在我的问题:

                  为什么定义了两个结构(冗余?),第一个的目的是什么,如果我什至无法访问它,因为没有绑定到任何类型/变量名.

                  Why are the two structs defined (redundantly?), what is the purpose of the first one, if I cannot even access it, due to not being bound to any type / variable name.

                  推荐答案

                  Microsoft 提供匿名结构作为 extension(他们的示例显示了另一个结构中的一个结构,但联合中的结构是相似的).如果您不介意基于其扩展名的不可移植代码,您可以使用以下内容:

                  Microsoft provides anonymous structs as an extension (their example shows one struct inside another struct, but a struct in a union is similar). If you don't mind non-portable code based on their extension, you can use things like:

                  LARGE_INTEGER a;
                  a.LowPart = 1;
                  

                  但是如果你想要可移植的代码,你需要:

                  but if you want portable code, you need:

                  a.u.LowPart = 1;
                  

                  联合让你可以使用.

                  这篇关于无法理解 LARGE_INTEGER 结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
                  Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
                  STL BigInt class implementation(STL BigInt 类实现)
                  Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
                  Move list element to the end in STL(在 STL 中将列表元素移动到末尾)
                  Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)

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

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

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

                              <tbody id='Sh9gT'></tbody>