工会_LARGE_INTEGER [英] union _LARGE_INTEGER

查看:85
本文介绍了工会_LARGE_INTEGER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不了解他们通过以下方式声明联盟的做法

i dont understand what they have done by declaring union in the follwing way

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




为什么他们在联合体内使用结构,以及QuadPart的用途是什么?




Why they have used structures within unions and what is the use of QuadPart?

推荐答案

其中一个结构被命名,另一个没有.
如果要将结构传递给某些函数,则可以使用命名的结构.
要直接使用结构的成员,直接使用未命名的结构会更方便.
如果您的编译器支持64位数字,则可以使用此联合将64位数字轻松拆分为32位部分.
One of the structure is named and the other isn''t.
If you want to pass the structure to some function, you would use the named structure.
To directly use the members of the structure it would be more convenient to use the unnamed structure directly.
If your compiler supports 64-bit numbers you can use this union to easily split the 64-bit number into 32-bit parts.


它们只是定义了多种访问数据的方式(工会的任务)您对此有何疑问?
:)
They just define multiple ways to access the data (that''s the task of unions) what is your doubt about?
:)


如您所知,最近出现了64位计算机.但是LARGE_INTEGER是64位变量.

如果要使用LARGE_INTEGER类型变量,则必须执行以下操作:

LARGE_INTEGER v;

v = 0x123456789; //->错误
v.QuadPart = 0x123456789; //可以正常工作
As you know, recently comes 64bit machine. But LARGE_INTEGER is 64bit variable.

If you want LARGE_INTEGER type variable, you have to do as follow:

LARGE_INTEGER v;

v = 0x123456789; //-> error
v.QuadPart = 0x123456789; // works OK


这篇关于工会_LARGE_INTEGER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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