为什么 GUID 结构是这样声明的?

发布于 2024-07-08 11:10:57 字数 487 浏览 5 评论 0原文

在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

Smile简单爱 2024-07-15 11:10:57

这是因为 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.

月朦胧 2024-07-15 11:10:57

http://en.wikipedia.org/wiki/Globally_Unique_Identifierhttp://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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文