Why is the GUID structure declared the way it is?

Posted by alabamasucks on Stack Overflow See other posts from Stack Overflow or by alabamasucks
Published on 2008-11-09T21:48:17Z Indexed on 2012/04/05 17:30 UTC
Read the original article Hit count: 140

Filed under:

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?

© Stack Overflow or respective owner

Related posts about guid