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

Martin Drasar drasar at ics.muni.cz
Tue Dec 20 09:00:02 PST 2011


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 who are interested:
The version produced by VisualD simply does not work and crashes. 
Hovewer, if you just execute dmd command that VisualD uses and then 
manually call cv2pdb, everything works fine and you can hapilly debug in 
Visual Studio.

Library compiled by VisualD:
----------------------------
DLibrary.dll | size: 936 082B
DLibrary.pdb | size: 248 832B

Library compiled by using VisualD commandline parameters:
---------------------------------------------------------
$ dmd dllmain.d -g -debug -X -Xf"DLibrary.json" -deps="DLibrary.dep" 
-of"..\Debug\DLibrary.dll" -map "DLibrary.map"

Results after calling cv2pdb on the DLibrary.dll

DLibrary.dll | size: 935 570B
DLibrary.pdb | size: 248 832B

Manual execution of that two commands produces library that works and is 
debugable and also, by some strange coincidence, 112 bytes smaller.

Funny... if you have any ideas, do not hesitate to share ;-)

Regards,
Martin


More information about the Digitalmars-d-learn mailing list