digitalmars.D.learn - How create Win32api Thread in Dlang?
- Marcone (18/18) Sep 25 2020 This is C++ code:
- Adam D. Ruppe (8/12) Sep 25 2020 extern(Windows)
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?
Sep 25 2020
On Saturday, 26 September 2020 at 03:08:56 UTC, Marcone wrote:#include <windows.h>import core.sys.windows.windowsWINAPIextern(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.
Sep 25 2020