Access to structures defined in C
Joe
jma at freedomcircle.com
Wed Mar 14 01:58:24 UTC 2018
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.
More information about the Digitalmars-d-learn
mailing list