d版运行时错误
if (vkCreateInstance(&createInfo, null, &instance) != VK_SUCCESS) {
...
}
官方错误基于异常:
class VKException : Exception
{
this(string msg)
{
super(msg);
}
}
void _()
{
if (vkCreateInstance(&createInfo, null, &instance) != VK_SUCCESS) {
throw new VKException("不能创建VK实例")
}
}
用std.exception.enforce比抛更可读.
enforce(vkCreateInstance(&createInfo, null, &instance) == VK_SUCCESS,"不能创建VK实例");
也可抛
enforce!VKException(/* ... */);
这样可编译语句:
__traits(compiles,{int* cMutable = &c;})
浙公网安备 33010602011771号