// foo.c typedef struct { unsigned bar; unsigned baz; } Foo; Foo setFoo(unsigned a, unsigned b) { Foo foo; foo.bar = a; foo.baz = b; } void setFooByPointer(unsigned a, unsigned b, Foo *pFoo) { pFoo->bar = a; pFoo->baz = b; } // strukt.d import std.stdio; struct Foo { uint bar; uint baz; } extern (C) Foo setFoo(uint a, uint b); extern (C) void setFooByPointer(uint a, uint b, Foo* pFoo); void main() { Foo foo; setFooByPointer(31337, 42, &foo); writeln(foo); foo = setFoo(31337, 42); writeln(foo); } // build $ dmd -c strukt.d -ofstrukt.o $ gcc -c foo.c -o foo.o $ dmd foo.o strukt.o -ofstrukt // run $ ./strukt Foo(31337, 42) Foo(42, 0) // expected: Foo(31337, 42) Foo(31337, 42)
Looks like issue 5570
Indeed. Sorry, search didn't point me to that one. *** This issue has been marked as a duplicate of issue 5570 ***