为什么Platform SDK以这种方式定义联合LARGE_INTEGER? [英] Why does Platform SDK define union LARGE_INTEGER in such a way?

查看:123
本文介绍了为什么Platform SDK以这种方式定义联合LARGE_INTEGER?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MSDN上找到了这些链接(LARGE_INTEGER& ULARGE_INTEGER的实现)

http://msdn.microsoft.com/en-us/library/windows/desktop/aa383713(v = vs.85).aspx [ ^ ]

http:// msdn.microsoft.com/en-us/library/windows/desktop/aa383742(v=vs.85).aspx [ ^ ]

I found these links on MSDN(Implementation of LARGE_INTEGER & ULARGE_INTEGER)
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383713(v=vs.85).aspx[^]
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383742(v=vs.85).aspx[^]

typedef union _LARGE_INTEGER {
  struct {
    DWORD LowPart;
    LONG  HighPart;
  };
  struct {
    DWORD LowPart;
    LONG  HighPart;
  } u;
  LONGLONG QuadPart;
} LARGE_INTEGER, *PLARGE_INTEGER;





谁能告诉我对前一个定义的考虑是什么,

和结构名称u是什么意思(意思是未签名?,我是

不确定。)?和为什么/我们应该在哪里使用LARGE_INTEG而不是_int64

提前谢谢



Who can tell me what the consideration for the former definition is,
and what does it mean by the struct name "u" (means "unsigned" ?, I'm
not sure.)? and Why/Where should we use LARGE_INTEGER instead of _int64
Thanks in advance

推荐答案

首先,结构u似乎是多余的。 Microsoft支持匿名结构: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx [ ^ ]



因此在Microsoft环境中你可以这样写:

Firstly the structure u seems redundant. Microsoft supports anonymous structures: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx[^]

Thus in a Microsoft environment you could write:
LARGE_INTEGER li;
li.LowPart = 1;





这是非 - 便携式,以便使其便携式添加指定的结构。现在你可以写:





This is non-portable so to make it portable the named structure u is added. Now you can write:

li.u.LowPart = 1;





在不支持_int64的地方使用它。



Use it where _int64 is not supported.


这篇关于为什么Platform SDK以这种方式定义联合LARGE_INTEGER?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆