On Tuesday, 9 May 2017 at 05:38:24 UTC, ag0aep6g wrote:
You have to create a new array of pointers. As rikki cattermole
has pointed out, you also have to null-terminate the individual
strings, and pass the amount of pointers in a separate
parameter.
----
import std.algorithm.iteration: map;
import std.array: array;
import std.conv: to;
import std.string: toStringz;
string[] strs = ["foo", "bar", "baz"];
/* convert string[] to char*[]: */
immutable(char)*[] chptrs = strs.map!toStringz.array;
immutable(char)** ppEnabledLayerNames = chptrs.ptr;
uint enabledLayerCount = chptrs.length.to!uint;
----
Although, if it's known that the array was populated with
literals, toStringz isn't needed. String literals are
automatically nul terminated.