On Monday, 6 June 2016 at 20:32:23 UTC, Alex Parrill wrote:
It relies on a lot of assumptions about the ABI that make a raw pointer work the same as a structure containing just one pointer, which is why I did not give it much consideration.

At least some of those assumptions could be verified at compile time:

    // insert at the end of the VkHandle mixin template:
    static assert(typeof(this).sizeof == typeof(bits).sizeof);
    static assert(typeof(this).alignof == typeof(bits).alignof);

If you want to be extra careful, you can also use a string mixin to declare each extern(C) function with its official C parameter types, plus a D pragma(inline, true) wrapper that accepts VkDevice or whatever, instead.

Of course, it's probably a lot easier to just tel your users to replace VK_NULL_HANDLE with VK_NULL_DISPATCHABLE or VK_NULL_NONDISPATCHABLE like you suggested earlier.

Reply via email to