[Issue 14309] New: The difference between Microsoft's GUID and std.uuid.UUID

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Mar 19 03:36:31 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14309

          Issue ID: 14309
           Summary: The difference between Microsoft's GUID and
                    std.uuid.UUID
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody at puremagic.com
          Reporter: zan77137 at nifty.com

In following code, I think it is hoped that `id` is the same as
`IID_IClassFactory`, why does this happen?

--------------
import std.stdio, core.sys.windows.com, std.uuid;

pragma(lib, "uuid"); // for IID_IClassFactory

void main()
{
  // IID of IClassFactory
  //
https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.ole.interop.iclassfactory.aspx
  immutable id = UUID("00000001-0000-0000-C000-000000000046");
  static assert(UUID.sizeof == 16);
  static assert(IID_IClassFactory.sizeof == 16);

  // 01 00 00 00 00 00 00 00 C0 00 00 00 00 00 00 46
  writefln("IID_IClassFactory: %(%02X %)",
*cast(ubyte[16]*)&IID_IClassFactory);
  // 00 00 00 01 00 00 00 00 C0 00 00 00 00 00 00 46
  writefln("std.uuid.UUID:     %(%02X %)", id.data);

  assert(id.data == *cast(ubyte[16]*)&IID_IClassFactory);   // failure
  assert(UUID("01000000-0000-0000-C000-000000000046").data
          == *cast(ubyte[16]*)&IID_IClassFactory);          // success
}

--


More information about the Digitalmars-d-bugs mailing list