为什么 GUID 结构是这样声明的?
在rpc.h中,GUID结构声明如下:
typedef struct _GUID
{
DWORD Data1;
WORD Data2;
WORD Data3;
BYTE Data[8];
} GUID;
我理解Data1、Data2和Data3。 它们在写出 GUID (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXX) 时定义第一组、第二组和第三组十六进制数字。
我一直不明白的是为什么最后两组在同一个字节数组中一起声明。 这不是更有意义吗(并且更容易编码)?
typedef struct _GUID
{
DWORD Data1;
WORD Data2;
WORD Data3;
WORD Data4;
BYTE Data5[6];
} GUID;
有人知道为什么这样声明吗?
In rpc.h, the GUID structure is declared as follows:
typedef struct _GUID
{
DWORD Data1;
WORD Data2;
WORD Data3;
BYTE Data[8];
} GUID;
I understand Data1, Data2, and Data3. They define the first, second, and third sets of hex digits when writing out a GUID (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX).
What I never understood was why the last 2 groups were declared together in the same byte array. Wouldn't this have made more sense (and been easier to code against)?
typedef struct _GUID
{
DWORD Data1;
WORD Data2;
WORD Data3;
WORD Data4;
BYTE Data5[6];
} GUID;
Anyone know why it is declared this way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为 GUID 是 UUID 的特殊情况。 有关所有字段含义的信息,您可以查看 RFC 4122。
It's because a GUID is a special case of a UUID. For information on what all the fields mean, you can look at RFC 4122.
http://en.wikipedia.org/wiki/Globally_Unique_Identifier 和 http://www.opengroup.org/onlinepubs/9629399/apdxa.htm(DCE 的原始表示,您可以在表格中看到位的分组)
http://en.wikipedia.org/wiki/Globally_Unique_Identifier and http://www.opengroup.org/onlinepubs/9629399/apdxa.htm (DCE's orginal representation, you can see the grouping of bits there in a table)