Two ways of receiving arrays on the C ABI

2020-10-19 Thread Ali Çehreli via Digitalmars-d-learn
On the D side, both of the following extern(C) functions take the same arguments. 1) func1 takes .length and .ptr implicitly as parts of a D array: extern(C) void func1(int[] arr) { assert(arr.equal(3.iota)); } 2) func2 takes .length and .ptr separately and then makes a slice explicitly:

Re: Two ways of receiving arrays on the C ABI

2020-10-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 20 October 2020 at 00:16:48 UTC, Ali Çehreli wrote: On the D side, both of the following extern(C) functions take the same arguments. https://github.com/dlang/dmd/pull/8120 there are issues with structs. Not sure about length/ptr.

Re: Two ways of receiving arrays on the C ABI

2020-10-20 Thread Ali Çehreli via Digitalmars-d-learn
On 10/19/20 6:28 PM, Nicholas Wilson wrote:> On Tuesday, 20 October 2020 at 00:16:48 UTC, Ali Çehreli wrote: >> On the D side, both of the following extern(C) functions take the same >> arguments. > > https://github.com/dlang/dmd/pull/8120 > > there are issues with structs. Not sure about length/

Re: Two ways of receiving arrays on the C ABI

2020-10-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-10-20 02:16, Ali Çehreli wrote: Everything works at least on Linux. Is this kosher, or am I using some internal knowledge? Yes, you're using some internal knowledge. You cannot assume it works on any other platform or architecture. In theory, the D compiler could choose to change the