betterC DLL in Windows

Tamas km212121 at
Sat Feb 4 18:29:41 UTC 2023

On Saturday, 4 February 2023 at 16:51:36 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> You don't have access to druntime/Phobos stuff at runtime.
> SimpleDllMain is for initializing and uninitializing druntime.
> See: 
> You want to only use ldc atm. The defaults right now should 
> most likely "just work" in dub for a single compile + link step 
> (i.e. only a single static library in dll).
> If you do it manually, you'll want to add the flag 
> ``--fvisibility=public`` to export everything.

I'm not sure I understand every bit of it yet, but this looks 
helpful, thank you.

I was able to compile this (based on dllmain.d linked by you) 
with both DMD and LDC:

module WindowsApp1;

version (Windows)
     version (D_BetterC)
         import : HINSTANCE, BOOL, DWORD, 

         extern (Windows) BOOL DllMain(HINSTANCE hInstance, DWORD 
ulReason, LPVOID reserved)
             return true;

         mixin SimpleDllMain;

export extern (C) void foo()
     import core.stdc.stdio : printf;

     printf("Hello betterC\n");

What's the reason to prefer LDC over DMD?

More information about the Digitalmars-d-learn mailing list