On Wednesday, 23 January 2013 at 17:14:31 UTC, Ali Çehreli wrote:
On 01/23/2013 08:33 AM, Sarath Kumar wrote:
> Can someone please tell me the right way to pass an opaque
object
> between module's functions.
I am assuming that you are interfacing with a C library. That
library must have a D binding file. I am assuming that it is
your libA.d:
There is also a library that implements the struct and the
functions. Although you would have it in the C library, here is
a D module to imitate it:
// libA_impl.d
// These are presumably defined in a C library. Simply
imitating it with this
// D module
extern (C)
{
struct Opaque
{
int i;
double d;
}
Opaque* getObject()
{
return new Opaque(42, 1.5);
}
void doSomething(Opaque *)
{}
}
I don't know the contents of the struct as libA and libB are 3rd
party C libraries.