Mike Parker:
I was expecting the length field to get in the way, but it
didn't seem to.
If you pass a fixed-sized array by ref it only passes the
pointer. The length is not passed, it's a compile-time known
value.
My question is, can I rely on this? Is there a guarantee that a
ref
On Monday, 9 December 2013 at 16:11:39 UTC, Jakob Ovrum wrote:
On Monday, 9 December 2013 at 15:46:40 UTC, Mike Parker wrote:
Given that on the C side, foo_t[3] parameters will degrade to
pointers, it's just as obvious to me to declare the function
on the D side like so:
extern( C ) void
On Monday, 9 December 2013 at 16:11:39 UTC, Jakob Ovrum wrote:
Upon consulting the specification[1], it looks like it's
officially recommended to use `ref T[n]` for C's `T[n]`, and
`T*` for C's `T[]`, in parameter lists.
[1] http://dlang.org/interfaceToC.html, Passing D Array
Arguments to C
Given the following declarations in C:
typedef int foo_t[3];
void take_foo( foo_t );
How would you handle this in D?
It's obvious to me that the type should be declared the same way, so
that it may be used the same way in D as in C:
alias foo_t = int[3];
Given that on the C side, foo_t[3]