digitalmars.D.learn - making a really simple dll.
- Charles McAnany <mcanance rose-hulman.edu> Aug 18 2011
- Trass3r <un known.com> Aug 18 2011
- Trass3r <un known.com> Aug 18 2011
- Adam D. Ruppe <destructionator gmail.com> Aug 18 2011
- Kai Meyer <kai unixlords.com> Aug 18 2011
- Trass3r <un known.com> Aug 18 2011
- Trass3r <un known.com> Aug 18 2011
- maarten van damme <maartenvd1994 gmail.com> Aug 18 2011
- Trass3r <un known.com> Aug 19 2011
Hi, all. I'm trying to write some efficient code for a macro in vba using a
language
that I enjoy. I don't need any fancy operating system interaction, I just want
to
write
int foo(int arg){
return arg; //actual computation a bit more involved.
}
Compile it to dll and call it with vba.
I looked at the dll documentation and I'm baffled by the time I get to the first
line: __gshared HINSTANCE g_hInst; and then it starts talking about
dll_process_attach. I don't want to attach processes, I want to compute an
integer.
Is there a simple way to make dlls, or is it going to be ugly to even write the
"Hello World" of dlls?
Cheers,
Charles
Aug 18 2011
I looked at the dll documentation and I'm baffled by the time I get to the first line: __gshared HINSTANCE g_hInst; and then it starts talking about dll_process_attach. I don't want to attach processes, I want to compute an integer.
The Dllmain is needed so the D runtime is properly initialized. Just copy the code http://www.d-programming-language.org/dll.html into a dllmain.d and put your actual code in other modules. You don't need to do the EXPORTS shit in the .def file though, just use the export keyword.
Aug 18 2011
Example: https://bitbucket.org/trass3r/matd/src/tip/examples/mmfile/
Aug 18 2011
We should make a mixin template DllMain that has a generic main.
import std.dll;
void myDllProc() { }
mixin DllMain!myDllProc;
I did this with my cgi.d and like it alot - the templated main saves
a lot of boilerplate.
Aug 18 2011
On 08/18/2011 01:32 PM, Trass3r wrote:Am 18.08.2011, 21:17 Uhr, schrieb Adam D. Ruppe <destructionator gmail.com>:We should make a mixin template DllMain that has a generic main.
We should also have a -shared switch that transparently includes all of the boilerplate crap: particularly the .def file, maybe even a default DllMain if none exists.
This would be my vote. -shared will: 1) check if there is a DllMain defined at the end, and if not, sticks a generic one in there 2) check if there are any exported functions (via .def or export()), if not, export them all That way, the OP's original simple 1 function d file compiles to a dll. Same goes for the Linux side. Default constructor and destructors that initialize and destroy the D runtime if there aren't any defined at the end of the compilation. -Kai Meyer
Aug 18 2011
Am 18.08.2011, 21:17 Uhr, schrieb Adam D. Ruppe <destructionator gmail.com>:We should make a mixin template DllMain that has a generic main.
We should also have a -shared switch that transparently includes all of the boilerplate crap: particularly the .def file, maybe even a default DllMain if none exists.
Aug 18 2011
Am 18.08.2011, 21:42 Uhr, schrieb Kai Meyer <kai unixlords.com>:2) check if there are any exported functions (via .def or export()), if not, export them all
That's insane. Larger projects have tons of functions and may only need to export a few. The language includes the export keyword to export functions and people should use it. dmd just needs to generate a .def file to make Optstink create a dll.
Aug 18 2011
--000e0cd29e4c5f4c3604aad27fd7 Content-Type: text/plain; charset=ISO-8859-1 "as for the linux side" I though dmd was unable to generate shared libs on linux? It would be cool to have a mixin "shared" that when compiled on windows generates a windows dll and if compiler on linux generates a linux shared lib :) 2011/8/18 Trass3r <un known.com>Am 18.08.2011, 21:42 Uhr, schrieb Kai Meyer <kai unixlords.com>: 2) check if there are any exported functions (via .def or export()), ifnot, export them all
That's insane. Larger projects have tons of functions and may only need to export a few. The language includes the export keyword to export functions and people should use it. dmd just needs to generate a .def file to make Optstink create a dll.
--000e0cd29e4c5f4c3604aad27fd7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable "as for the linux side"<br>I though dmd was unable to generate sh= ared libs on linux?<br><br>It would be cool to have a mixin "shared&qu= ot; that when compiled on windows generates a windows dll and if compiler o= n linux generates a linux shared lib :)<br> <br><div class=3D"gmail_quote">2011/8/18 Trass3r <span dir=3D"ltr"><<a h= ref=3D"mailto:un known.com">un known.com</a>></span><br><blockquote clas= s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad= ding-left:1ex;"> Am 18.08.2011, 21:42 Uhr, schrieb Kai Meyer <<a href=3D"mailto:kai unixl= ords.com" target=3D"_blank">kai unixlords.com</a>>:<div class=3D"im"><br=
x #ccc solid;padding-left:1ex"> 2) check if there are any exported functions (via .def or export()), if not= , export them all<br> </blockquote> <br></div> That's insane. Larger projects have tons of functions and may only need= to export a few.<br> The language includes the export keyword to export functions and people sho= uld use it.<br> dmd just needs to generate a .def file to make Optstink create a dll.<br> </blockquote></div><br> --000e0cd29e4c5f4c3604aad27fd7--
Aug 18 2011
Am 19.08.2011, 04:29 Uhr, schrieb maarten van damme <maartenvd1994 gmail.com>:"as for the linux side" I though dmd was unable to generate shared libs on linux?
But GDC and LDC are.
Aug 19 2011









Kai Meyer <kai unixlords.com> 