Re: What exactly gets returned with extern(C) export string func() ?

2021-06-16 Thread frame via Digitalmars-d-learn
On Wednesday, 16 June 2021 at 02:46:36 UTC, cc wrote: I can't seem to get it to work as a return type, but interestingly it does work as an out/pass by ref parameter. Probably for returning the struct it needs some allocation directive in C# but I'm not sure. Maybe C# also tries something

Re: What exactly gets returned with extern(C) export string func() ?

2021-06-15 Thread cc via Digitalmars-d-learn
On Sunday, 13 June 2021 at 21:13:33 UTC, frame wrote: On Sunday, 13 June 2021 at 10:02:45 UTC, cc wrote: it seems to work as expected with the same C# code. Does D explicitly disallow slices as an extern(C) export parameter type? The spec says that there is no equivalent to type[]. You get

Re: What exactly gets returned with extern(C) export string func() ?

2021-06-13 Thread frame via Digitalmars-d-learn
On Sunday, 13 June 2021 at 10:02:45 UTC, cc wrote: it seems to work as expected with the same C# code. Does D explicitly disallow slices as an extern(C) export parameter type? The spec says that there is no equivalent to type[]. You get a type* instead.

What exactly gets returned with extern(C) export string func() ?

2021-06-13 Thread cc via Digitalmars-d-learn
D under dmd/Win10/64-bit currently seems to store strings (slices) internally like so: ```d static struct DString { size_t length; immutable(char)* ptr; } static assert(DString.sizeof == string.sizeof); string s = "abcde"; DString d; memcpy(, , s.sizeof); assert(d.length ==