how to pass a ubyte[] to c interface?

zhmt via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 12 23:47:05 PDT 2015


On Friday, 13 March 2015 at 06:39:31 UTC, Rikki Cattermole wrote:
> On 13/03/2015 7:35 p.m., zhmt wrote:
>> ubyte[] arr ;
>>
>> I pass the arr.ptr to c program, it fails silently.
>>
>> Is there any way to cast a ubyte[] to a clang pointer?
>
> Theoretically this should work.
>
> D:
>
> void func(ubyte[] value) {
> 	func(value.length, value.ptr);
> }
>
> extern(C) void func(size_t length, ubyte*);
>
> C:
> void func(size_t length, ubyte*) {
> 	// ...
> }

Thank you for your confirm,I will try again.


More information about the Digitalmars-d-learn mailing list