Re: Creating DLL

2022-06-16 Thread Sergeant via Digitalmars-d-learn
On Thursday, 16 June 2022 at 16:19:22 UTC, Ali Çehreli wrote: On 6/16/22 09:07, Sergeant wrote: This answer may be relevant: https://forum.dlang.org/post/t8diks$2l79$1...@digitalmars.com Ali, thank you, I'll take a look.

Re: Creating DLL

2022-06-16 Thread Sergeant via Digitalmars-d-learn
Adam, thank you again! Adding Initialize()/Terminate() to code and calling from my application as you suggested didn't help, unfortunately. Maybe the problem is in the scripting language I'm using (AHK) which is not designed to handle situations like these. In any case, appreciate your help!

Re: Creating DLL

2022-06-16 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 16 June 2022 at 16:37:34 UTC, Ali Çehreli wrote: Agreed but that excludes using the D runtime in 'static this' (and shared) blocks, right? It is runtime.initialize that calls those `static this` blocks. If my explicit call to Initialize is in a 'shared static this' This is back

Re: Creating DLL

2022-06-16 Thread Ali Çehreli via Digitalmars-d-learn
On 6/16/22 09:32, Adam D Ruppe wrote: > This is why an explicit initialization call is the preferred method - > there, the time it is called is well-defined by the user after initial > loading is complete. Agreed but that excludes using the D runtime in 'static this' (and shared) blocks, right?

Re: Creating DLL

2022-06-16 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 16 June 2022 at 16:19:22 UTC, Ali Çehreli wrote: pragma (crt_constructor) You have to be pretty careful about this since it might not run in the order you expect. If there's two things in the program with a equal-priority crt constructor, they are run in arbitrary order. In a sh

Re: Creating DLL

2022-06-16 Thread Ali Çehreli via Digitalmars-d-learn
On 6/16/22 09:07, Sergeant wrote: > May I ask one more question: why a code like this would work in > D-application but not in D-DLL? D programs generated by D compilers automatically initialize the D runtime. You can do the same with rt_init: pragma (crt_constructor) extern(C) int initialize

Re: Creating DLL

2022-06-16 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 16 June 2022 at 16:07:41 UTC, Sergeant wrote: May I ask one more question: why a code like this would work in D-application but not in D-DLL? (also I notice some other D functions don't work in DLL): Probably because the runtime not initialized properly. Export an Initialize() an

Re: Creating DLL

2022-06-16 Thread Sergeant via Digitalmars-d-learn
Adam thank you, it works now! May I ask one more question: why a code like this would work in D-application but not in D-DLL? (also I notice some other D functions don't work in DLL): import std.string; export extern(C) string my(string input) { string output

Re: Creating DLL

2022-06-16 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 16 June 2022 at 13:57:48 UTC, Sergeant wrote: export int my(int a, int b) the name here is going to be mangled, so like "_D5mydll2myiiZi" or something like that. You might want to add `extern(C)` to it so it keeps the simple name "my", that might help.

Creating DLL

2022-06-16 Thread Sergeant via Digitalmars-d-learn
Hi, I wonder if anyone knowledgeable can point me in the right direction here. I created DLL in Visual D, but when I try to use it by my application (AHK script), DLL itself is loaded ok, but error is set to "specified function could not be found inside the DLL". (Same DLL that I made in C++ w