digitalmars.D - exporting classes DLL
- Joe Meilinger (21/21) Dec 20 2004 Are class exports allowed in D? I create the DLL and then pull the LIB ...
- Chris Sauls (23/27) Dec 20 2004 If I remember right, due to some detail in how DLL's work, you have to
Are class exports allowed in D? I create the DLL and then pull the LIB using
implib/system. The C function "Testit()" works fine, but adding in a TestC
class instantiation (with or without "Point." prepended) doesn't work. I'm
using the stock dll.d.
*****Point.d*****
export {
void Testit() { printf( "Hello\n");}
class TestC
{
this() {}
void Testit() { printf( "Class testit\n");}
int i;
}
}
*****dlltest.d*****
import Point;
void main(char [][]args)
{
Point.Testit();
TestC dllclass = new TestC();
}
Dec 20 2004
If I remember right, due to some detail in how DLL's work, you have to provide a function to return either an instance of the Class or a delegate to a static factory method, or some such. Aka, something like the following: I know this has come up before, but since I don't personally usually use DLL's anyhow, I might not remember exaclty right. Best to search the newsgroup. Maybe once constructor delegates are available from ClassInfo references this will become simpler. (Hint hint, Walter. :) ) -- Chris Sauls Joe Meilinger wrote:Are class exports allowed in D? I create the DLL and then pull the LIB using implib/system. The C function "Testit()" works fine, but adding in a TestC class instantiation (with or without "Point." prepended) doesn't work. I'm using the stock dll.d.
Dec 20 2004








Chris Sauls <ibisbasenji gmail.com>