Re: Allocating memory in D shared library when accessed from C++

2011-12-20 Thread Martin Drasar
Dne 20.12.2011 2:22, Andrej Mitrovic napsal(a): test.cpp: http://www.ideone.com/uh7vN DLibrary.d: http://www.ideone.com/fOLN8 $ g++ test.cpp $ dmd -ofDLibrary.dll DLibrary.d $ a.exe $ 9 Hi, Andrej, you are right, this works. Problem is going to be either in VisualD or cv2pdb. For those

Re: Allocating memory in D shared library when accessed from C++

2011-12-20 Thread Andrej Mitrovic
I'd say make a small test-case and file it to visuald's bugtracker.

Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Martin Drasar
Hello everyone, I would like to ask you about linking D shared objects (.dll and .so) from a C++ program. Say I have this C++ loader: typedef int (*MagicFunction) (); HMODULE handle = LoadLibraryA(DLibrary.dll); if (handle) { MagicFunction fn = (MagicFunction) GetProcAddress(handle,

Re: Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Andrej Mitrovic
Check if GetProcAddress returns null? It seems to me you're looking for _magicFunction but defining magicNumber, two different names.

Re: Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Simon
On 19/12/2011 18:01, Andrej Mitrovic wrote: Check if GetProcAddress returns null? It seems to me you're looking for _magicFunction but defining magicNumber, two different names. that's be it. can't remember the rules for whether it will have a leading underscore, but you can always use

Re: Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Martin Drašar
Dne 19.12.2011 19:39, Simon napsal(a): On 19/12/2011 18:01, Andrej Mitrovic wrote: Check if GetProcAddress returns null? It seems to me you're looking for _magicFunction but defining magicNumber, two different names. that's be it. can't remember the rules for whether it will have a leading

Re: Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Trass3r
It actualy returns a procedure address and the procedure is called. It lands inside export extern (C) int magicNumber() and crashes when attempting to allocate memory for Something. Did you properly initialize druntime?

Re: Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Martin Drašar
Dne 19.12.2011 23:09, Trass3r napsal(a): It actualy returns a procedure address and the procedure is called. It lands inside export extern (C) int magicNumber() and crashes when attempting to allocate memory for Something. Did you properly initialize druntime? As I am just starting with D,

Re: Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Trass3r
Am 19.12.2011, 23:13 Uhr, schrieb Martin Drašar dra...@ics.muni.cz: Dne 19.12.2011 23:09, Trass3r napsal(a): It actualy returns a procedure address and the procedure is called. It lands inside export extern (C) int magicNumber() and crashes when attempting to allocate memory for Something.

Re: Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Martin Drašar
Dne 20.12.2011 0:02, Trass3r napsal(a): Am 19.12.2011, 23:13 Uhr, schrieb Martin Drašar dra...@ics.muni.cz: Dne 19.12.2011 23:09, Trass3r napsal(a): It actualy returns a procedure address and the procedure is called. It lands inside export extern (C) int magicNumber() and crashes when

Re: Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Andrej Mitrovic
test.cpp: http://www.ideone.com/uh7vN DLibrary.d: http://www.ideone.com/fOLN8 $ g++ test.cpp $ dmd -ofDLibrary.dll DLibrary.d $ a.exe $ 9