(How) can I make a constant that is either zero or null depending on how it is used?

Vulkan has a VK_NULL_HANDLE constant which in C is defined to be zero. It is used as a null object for several types of objects. In D however, zero is not implicitly convertible to a null pointer, and vice versa.

On 64 bit platforms, those types are all pointers, so there I can define VK_NULL_HANDLE as null. But on 32 bit platforms, some of the types are pointers and others are ulongs, and my definition of VK_NULL_HANDLE should be compatible with both.

Anyone have an idea on how to make this work?

Reply via email to