www.digitalmars.com         C & C++   DMDScript  

D - sharing objects between dlls

reply "Vathix" <Vathix dprogramming.com> writes:
I would like my program to pass a class object to a function in a D dll, I
have the address of the function but I don't know how to interface it in the
dll. I think it has to do with exporting the class from my exe, but I don't
know how that works either.  Please help, thanks.
Jun 24 2003
parent reply "Walter" <walter digitalmars.com> writes:
"Vathix" <Vathix dprogramming.com> wrote in message
news:bd9q40$1kt7$1 digitaldaemon.com...
 I would like my program to pass a class object to a function in a D dll, I
 have the address of the function but I don't know how to interface it in

 dll. I think it has to do with exporting the class from my exe, but I

 know how that works either.  Please help, thanks.

Richter's book on NT programming from www.digitalmars.com/bibliography.html is essential for understanding how DLL's work and how to create and use them.
Jun 24 2003
parent reply "Vathix" <Vathix dprogramming.com> writes:
"Walter" <walter digitalmars.com> wrote in message
news:bd9s26$1mmg$4 digitaldaemon.com...
 "Vathix" <Vathix dprogramming.com> wrote in message
 news:bd9q40$1kt7$1 digitaldaemon.com...
 I would like my program to pass a class object to a function in a D dll,


 have the address of the function but I don't know how to interface it in

 dll. I think it has to do with exporting the class from my exe, but I

 know how that works either.  Please help, thanks.

Richter's book on NT programming from

 is essential for understanding how DLL's work and how to create and use
 them.

I've used dlls in C many times (and C compatible D dlls), I don't think I have a problem with that. What I want here is to use it with D classes. I can't just pass my D class object to a function in a D dll and have it able to access this object, it has to know about the members and such, that's where I'm stuck. The only way I think I could do it now is to compile the class code in the exe and dll, but I don't think that's good because it's wasting space (and defeats the purpose of exporting a class ?) and it's not guaranteed to have the same memory layout (class.html "The D compiler is free to rearrange the order of fields in a class"...).
Jun 24 2003
next sibling parent Patrick Down <Patrick_member pathlink.com> writes:
In article <bd9ukm$1p00$1 digitaldaemon.com>, Vathix says...

The only way I think I could do it now is to compile the class code in the
exe and dll, but I don't think that's good because it's wasting space (and
defeats the purpose of exporting a class ?) and it's not guaranteed to have
the same memory layout (class.html "The D compiler is free to rearrange the
order of fields in a class"...).

You don't have to compile the class code into the exe you just need to import it. The rearranging is an interesting issue but any given D compiler from a vendor will layout a class in the same way across compiles. Even obj files would have an issue if this were not true. Perhaps between D compiler vendors some sort of statndard can be determined to make class layouts the same.
Jun 24 2003
prev sibling parent "Walter" <walter digitalmars.com> writes:
"Vathix" <Vathix dprogramming.com> wrote in message
news:bd9ukm$1p00$1 digitaldaemon.com...
 I've used dlls in C many times (and C compatible D dlls), I don't think I
 have a problem with that. What I want here is to use it with D classes. I
 can't just pass my D class object to a function in a D dll and have it

 to access this object, it has to know about the members and such, that's
 where I'm stuck.

Just import the module in the source code to the DLL, but don't link it in.
Jul 02 2003