#include <Windows.h>
#include <cstdio>
struct Arith
{
void arithmetic()
{
std::printf("unko\n");
}
static DWORD __stdcall thread_entry_point(VOID *param)
{
auto *pa = static_cast<Arith *>(param);
pa->arithmetic();
return 0;
}
};
int main()
{
auto *pa = new Arith;
DWORD tid;
auto h = ::CreateThread(nullptr, 0, Arith::thread_entry_point, pa, 0, &tid);
if ( h == nullptr )
throw "oops...";
std::printf("[main] started\n");
::WaitForSingleObject(h, INFINITE);
std::printf("[main] joined\n");
}
I2luY2x1ZGUgPFdpbmRvd3MuaD4KI2luY2x1ZGUgPGNzdGRpbz4KCnN0cnVjdCBBcml0aAp7CiAgICB2b2lkIGFyaXRobWV0aWMoKQoJewoJCXN0ZDo6cHJpbnRmKCJ1bmtvXG4iKTsKCX0KCglzdGF0aWMgRFdPUkQgX19zdGRjYWxsIHRocmVhZF9lbnRyeV9wb2ludChWT0lEICpwYXJhbSkKCXsKCQlhdXRvICpwYSA9IHN0YXRpY19jYXN0PEFyaXRoICo+KHBhcmFtKTsKCQlwYS0+YXJpdGhtZXRpYygpOwoKCQlyZXR1cm4gMDsKCX0KfTsKCmludCBtYWluKCkKewoJYXV0byAqcGEgPSBuZXcgQXJpdGg7CglEV09SRCB0aWQ7CglhdXRvIGggPSA6OkNyZWF0ZVRocmVhZChudWxscHRyLCAwLCBBcml0aDo6dGhyZWFkX2VudHJ5X3BvaW50LCBwYSwgMCwgJnRpZCk7CglpZiAoIGggPT0gbnVsbHB0ciApCgkJdGhyb3cgIm9vcHMuLi4iOwoJc3RkOjpwcmludGYoIlttYWluXSBzdGFydGVkXG4iKTsKCTo6V2FpdEZvclNpbmdsZU9iamVjdChoLCBJTkZJTklURSk7CglzdGQ6OnByaW50ZigiW21haW5dIGpvaW5lZFxuIik7Cn0K