Pointer to std.container.Array data for C library

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 28 11:40:31 PDT 2015


On Friday, 28 August 2015 at 18:31:00 UTC, Oleg wrote:
> On Friday, 28 August 2015 at 18:21:04 UTC, John Colvin wrote:
>> On Friday, 28 August 2015 at 17:45:21 UTC, Oleg wrote:
>>> Hello!
>>> Is it possible to get pointer to a data in 
>>> std.container.Array like .ptr from an array? I need to pass a 
>>> pointer to some C function (from DerelictGL3 binding) and 
>>> avoid GC allocation.
>>> Thank you!
>>
>> I'm pretty sure you can just take the address of the first 
>> element, e.g. &a[0] or &a.front
>
> I've tried, it throws
> core.exception.RangeError@/usr/include/dmd/phobos/std/container/array.d(571): Range violation

That's unexpected. Could you provide a full example that does 
this?


More information about the Digitalmars-d-learn mailing list