为什么以这种方式声明GUID结构? [英] Why is the GUID structure declared the way it is?
问题描述
在rpc.h中,GUID结构声明如下:
In rpc.h, the GUID structure is declared as follows:
typedef struct _GUID
{
DWORD Data1;
WORD Data2;
WORD Data3;
BYTE Data[8];
} GUID;
我了解Data1,Data2和Data3.当写出GUID(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX)时,它们定义了第一,第二和第三组十六进制数字.
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?
推荐答案
这是因为GUID是 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.
这篇关于为什么以这种方式声明GUID结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!