Exception when creating a Thread with Windows
Steven Schveighoffer
schveiguy at gmail.com
Sat Jul 5 10:52:21 UTC 2025
On Saturday, 5 July 2025 at 10:39:13 UTC, stef wrote:
> Hello,
>
> I'm totally new using D. I'm trying to create a thread using
> this code:
>
>
> ```d
> …
> extern (Windows)
> int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
> LPSTR lpCmdLine, int nCmdShow)
> …
>
> ```
>
> I'm testing this program using Visual Studio Code. I
> systematically have an exception (not trapped, I don't know why
> by the catch) when it's calling thread.start(). I can see it
> only with the debugger.
>
> The exception is:
>
> W32/0xC0000005
> Unhandled exception at 0x00007FFB5F379463 (ntdll.dll) in
> threads-debug.exe: 0xC0000005: Access violation writing
> location 0x0000000000000024.
>
> Is it a mistake or a bug ?
By using WinMain, You are bypassing the runtime startup.
Check out this article: https://wiki.dlang.org/D_for_Win32
-Steve
More information about the Digitalmars-d-learn
mailing list