https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117514

--- Comment #3 from Jordan <8e3g6jay6 at mozmail dot com> ---
So another update to this. If I do it like this, I simply get a crash of:
Operating system error: Cannot allocate memory
Memory allocation failure in xrealloc


  function check_device_extension_support(physical_device) result(has_support)
    implicit none

    !VkPhysicalDevice
    integer(c_int64_t), intent(in), value :: physical_device
    logical(c_bool) :: has_support
    integer(c_int32_t) :: extension_count
    ! VkExtensionProperties
    type(vec) :: available_extensions
    ! character(:)
    type(vec) :: required_device_extensions
    type(vk_extension_properties), pointer :: extension_properties
    character(len = :, kind = c_char), pointer :: required_extension
    integer(c_int32_t) :: i


    if (vk_enumerate_device_extension_properties(physical_device, c_null_ptr,
extension_count, c_null_ptr) /= VK_SUCCESS) then
      error stop "[Vulkan] Error: Failed to enumerate device extension
properties."
    end if

    call create_required_device_extensions(required_device_extensions)

    call c_f_pointer(required_device_extensions%get(1_8), required_extension)

    print*,required_extension

  end function check_device_extension_support


  subroutine create_required_device_extensions(required_device_extensions)
    implicit none

    ! character *
    type(vec), intent(inout) :: required_device_extensions
    character(len = :, kind = c_char), pointer :: required_extension

    required_device_extensions = new_vec(sizeof(c_null_ptr), 0_8)

    allocate(character(len = 32, kind = c_char) :: required_extension)
    required_extension = "VK_KHR_SWAPCHAIN_EXTENSION_NAME"//achar(0)

    call required_device_extensions%push_back(required_extension)

  end subroutine create_required_device_extensions

Reply via email to