What is the correct way to declare and access storage managed by C?

For example, say a C module defines an array of filenames, e.g.,

char *files[] = { "one", "two", "three", 0};

The C header of course declares this as:

extern char *files[];

The way to declare it in a D module appears to be:

extern (C) {
   __gshared extern char *[] files;
}

However, trying to index into this, e.g.,

char *filename = files[1];

does not work. In gdb if I try to examine 'filename' I see something like a reverse text string but treated as an (inaccessible) address and calling fromStringz causes a segfault.

Reply via email to