September 26, 2020 How create Win32api Thread in Dlang? | ||||
---|---|---|---|---|
| ||||
This is C++ code: #include <windows.h> WINAPI DWORD threadFunc(LPVOID x) { while (true) { try { throw 1; } catch (...) { } } return 0; } int main(int argc, char *argv[]) { CreateThread(NULL, 0, threadFunc, NULL, 0, NULL); CreateThread(NULL, 0, threadFunc, NULL, 0, NULL); Sleep(1000); return 0; } How can I convert it to Dlang? |
September 26, 2020 Re: How create Win32api Thread in Dlang? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marcone | On Saturday, 26 September 2020 at 03:08:56 UTC, Marcone wrote: > #include <windows.h> import core.sys.windows.windows > WINAPI extern(Windows) > int main(int argc, char *argv[]) { int main(string[] args) > CreateThread(NULL, 0, threadFunc, NULL, 0, NULL); CreateThread(null, 0, &threadFunc, null, 0, null); Maybe minor compile errors like required casts but this is really about it. You can almost literally copy/paste most C examples to D. |
Copyright © 1999-2021 by the D Language Foundation