Converting a string[] to char**
rikki cattermole via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon May 8 22:03:23 PDT 2017
On 09/05/2017 5:22 AM, David Zhang wrote:
> Hi,
>
> I'm playing around with Vulkan, and part of its initialization code
> calls for an array of strings as char**. I've tried casting directly
> (cast(char**)) and breaking it down into an array of char*s (char*[])
> before getting the pointer to its first element (&a[0]). It provides the
> correct type, but Vulkan rejects it. Is there a standard way of doing this?
>
> I'm trying to set the ppEnabledExtensionNames member of
> VkInstanceCreateInfo.
>
> Regards,
> David
From docs:
"ppEnabledLayerNames is a pointer to an array of enabledLayerCount
null-terminated UTF-8 strings containing the names of layers to enable
for the created instance. See the Layers section for further details."
Note each string is null terminated.
You also have to set enabledLayerCount to the length of the string array.
There is toStringz in std.string that'll help here for null terminating.
If you're already doing all this, no idea then.
More information about the Digitalmars-d-learn
mailing list