Interfacing with C - calling member function of D struct from C?

unleashy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 24 19:05:35 PDT 2017


Hello! If I have a D struct like:

struct Foo
{
     int bar;

     void addToBar(int what) {
         bar += what;
     }
}

How would I call `addToBar` from C code? Would I need to put the 
`addToBar` function outside of the struct and mark it as `extern 
(C)` and in normal D code take advantage of UFCS or is there some 
magic C incantation?

I've scoured the forums and other places for anything about this 
but couldn't find any information whatsoever... so yeah. (or my 
Google-fu is terrible)

Thanks!


More information about the Digitalmars-d-learn mailing list