D struct with String type accessing from Python

Ali Çehreli acehreli at yahoo.com
Tue Dec 27 19:02:51 UTC 2022


On 12/27/22 10:31, cc wrote:

 > No need for extern(C#), extern(C) should be sufficient.

Sure but you are not using extern(C) for your D example. (?)

I find quotes like this: "C defines no ABI. In fact, it bends over 
backwards to avoid defining an ABI."

At least we have this guarantee: "D is designed to fit comfortably with 
a C compiler for the target system.":

   https://dlang.org/spec/interfaceToC.html#structs_and_unions

 > This doesn't work (D):
 > ```d
 > export auto MyDLL_testStringReturn() {
 >      string s = "hello";
 >      return s;
 > }

But that's not extern(C).

There must be clues on the following page but it doesn't show anything 
special for returning arrays nor it specifies whether an array is the 
same as a struct with 2 members. (We know it is equivalent but it 
doesn't say it is the same as a struct definition.)

   https://dlang.org/spec/abi.html#return_value

Ali



More information about the Digitalmars-d mailing list