openlang

What does `[*c]VkPhysicalDevice` stand for?

Searching hasn't turned up an answer for me, although this may well have appeared in ziglings and slipped my memory.

I'm bringing in Vulkan as a system library using translate_c on Zig 0.17.0. The resulting declaration looks like this:

pub extern fn vkEnumeratePhysicalDevices(instance: VkInstance, pPhysicalDeviceCount: [*c]u32, pPhysicalDevices: [*c]VkPhysicalDevice) VkResult;

What puzzles me is the meaning of [*c]. Does it merely say this should point at an array's initial element?

The following finally compiled for me, although I suspect there's a more conventional way to write it.

    var adapters = try allocator.alloc(vulkan.VkPhysicalDevice, adapter_count);
    _ = vulkan.vkEnumeratePhysicalDevices(instance, &adapter_count,
        @ptrCast(&adapters[0]));

Thanks beforehand for any pointers!

The conversation continues 2

Follow the reasoning

Other sides of the same question

  1. Delaying a cleanup block's mutable borrow until it actually runs

    What would be a way for me to write a panic-safe mecanism in Rust that behaves similarly to Java's try { ... } finally { ...…

    Replies 2Latest activity rust
  2. Inputting character arrays through pointers

    Whenever I attempt keyboard input into some char arrays, my program ends up crashing. What's a straightforward way of reading…

    Replies 2Latest activity c
  3. Can an input function avoid relying on global variables?

    I'd like a function to process what a user enters, filter it, and return the resulting string to whichever function called it…

    Replies 2Latest activity c