为什么D将此功能标记为纯粹的nothrow @nogc?

时间:2016-05-22 18:39:30

标签: d

alias PFN_vkDebugReportCallbackEXT = 
  VkBool32 function(VkDebugReportFlagsEXT flags,
                    VkDebugReportObjectTypeEXT objectType,
                    uint64_t object, size_t location, 
                    int32_t messageCode, const char* pLayerPrefix,
                    const char* pMessage, void* pUserData);

struct VkDebugReportCallbackCreateInfoEXT {
    VkStructureType               sType = VkStructureType.VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
    const(void)*                  pNext;
    VkDebugReportFlagsEXT         flags;
    PFN_vkDebugReportCallbackEXT  pfnCallback;
    void*                         pUserData;
}

...

VkBool32 MyDebugReportCallback(
    VkDebugReportFlagsEXT       flags,
    VkDebugReportObjectTypeEXT  objectType,
    uint64_t                    object,
    size_t                      location,
    int32_t                     messageCode,
    const char*                 pLayerPrefix,
    const char*                 pMessage,
    void*                       pUserData)
{
    return VK_FALSE;
}
auto debugcallbackCreateInfo = VkDebugReportCallbackCreateInfoEXT(
    VkStructureType.VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT,
    null,
    VkDebugReportFlagBitsEXT.VK_DEBUG_REPORT_ERROR_BIT_EXT,
    &MyDebugReportCallback,
    null
);
  

错误:无法隐式转换表达式(& MyDebugReportCallback)   类型uint函数(uint标志,VkDebugReportObjectTypeEXT   objectType,ulong对象,ulong位置,int messageCode,   const(char *)pLayerPrefix,const(char *)pMessage,void * pUserData)to   uint函数(uint标志,VkDebugReportObjectTypeEXT objectType,ulong   object,ulong location,int messageCode,const(char *)pLayerPrefix,   const(char *)pMessage,void * pUserData)pure nothrow @nogc

我不明白为什么PFN_vkDebugReportCallbackEXT是纯粹的nothrow和@nogc?我只想在writeln内致电MyDebugReportCallback

1 个答案:

答案 0 :(得分:0)

答案很明显。它位于一个纯粹的,无意义的和@nogc块中

https://github.com/ParticlePeter/ErupteD/blob/master/source/erupted/types.d#L12