D struct with String type accessing from Python

alchemypy me at alchemypy.com
Wed Dec 28 02:20:50 UTC 2022


On Tuesday, 27 December 2022 at 18:31:34 UTC, cc wrote:
> On Tuesday, 27 December 2022 at 17:04:03 UTC, Ali Çehreli wrote:
>> I don't know C# to be sure but it must be ABI related. The way 
>> D passes returned objects must be different from what C# 
>> expects. (There is no extern(C#) to rely on here. ;) )
>
> No need for extern(C#), extern(C) should be sufficient.  
> However, how does D pass a D slice as a return value under 
> extern(C)?  Does it just return nothing at all?  Returning a 
> struct that is the same size as a D slice and memcpy'd from one 
> works.


I may be wrong (Please ignore this if i am wrong) , This example 
will return String from D to C#. however the actual issue is (the 
challenge i am facing is) i am not able to call a D function 
which has Struct parameter with String property.

I am trying to see how i can call Print_gph function which has 
Struct parameter with String property.

	struct gph
	{
		string x;
	}

	struct myStruct
	{
		pragma(mangle, "Print_gph")
		void Print_gph(gph g)
		{
			stderr.writeln("here: gph ");
			stderr.writeln(g.x);
		
		}
	}


More information about the Digitalmars-d mailing list