digitalmars.D.learn - making a really simple dll.
- Charles McAnany (14/14) Aug 18 2011 Hi, all. I'm trying to write some efficient code for a macro in vba usin...
- Trass3r (5/10) Aug 18 2011 The Dllmain is needed so the D runtime is properly initialized.
- Trass3r (2/2) Aug 18 2011 Example:
- Adam D. Ruppe (6/6) Aug 18 2011 We should make a mixin template DllMain that has a generic main.
- Trass3r (5/6) Aug 18 2011 We should also have a -shared switch that transparently includes all of ...
- Kai Meyer (11/17) Aug 18 2011 This would be my vote. -shared will:
- Trass3r (6/8) Aug 18 2011 That's insane. Larger projects have tons of functions and may only need ...
- maarten van damme (6/15) Aug 18 2011 "as for the linux side"
- Trass3r (3/5) Aug 19 2011 But GDC and LDC are.
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
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
On 08/18/2011 01:32 PM, Trass3r wrote:Am 18.08.2011, 21:17 Uhr, schrieb Adam D. Ruppe <destructionator gmail.com>: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 MeyerWe 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 allThat'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
"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 allThat'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
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