In D, the array is actually (conceptually):
struct { size_t length; void* ptr; };
The usual way to get a pointer from an array is to use the .ptr field. In your case: myCFunction(dArray.ptr);
But will this pointer only point to the first element
Since the elements are stored contiguously in memory, a pointer to the first element is all we need. We simply add an offset to this pointer if we want to get the addresses of other elements.
Another point: usually, if the C function wants an array pointer, it also has an argument for the length of the array. In most cases, you can give it dArray.length , but sometimes it actually asks for the size in bytes, not the number of elements.
source share