Fixed Length Array Syntax in extern(C) Function Signatures
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jul 9 20:18:21 PDT 2015
On Thursday, 9 July 2015 at 17:42:33 UTC, Alex Parrill wrote:
> On Thursday, 9 July 2015 at 17:11:36 UTC, Per Nordlöw wrote:
>> On Thursday, 9 July 2015 at 16:12:27 UTC, Timon Gehr wrote:
>>> No. You'll need explicit pass by reference on the D side.
>>
>> So, how should I modify my call to `image_copy` with respect
>> to the four first parameters?
>
> In C, array parameters are the same as pointers; i.e. `foo(T[]
> arg)` is the same as `foo(T* arg)` [1].
>
> You should just be able to replace `[4]` with `*` in the
> arguments.
>
> [1]: http://stackoverflow.com/a/5573741/646619
Static arrays in C function parameter lists should be declared as
ref on the D side. See "Passinbg D Array Arguments to C
Functions" at [1]. So the function declaration above in D should
be:
void av_image_copy(ref ubyte *[4] dst_data, ref int[4]
dst_linesizes,
ref const ubyte *[4] src_data, ref const
int[4] src_linesizes,
AVPixelFormat pix_fmt, int width, int
height)
[1]http://dlang.org/interfaceToC.html
More information about the Digitalmars-d-learn
mailing list