Code: Select all
#include <stdio.h>
#include <windows.h>
#include <process.h>
int main() {
/* DWORD WINAPI */void input(/* LPVOID */void* lpParam) {
Sleep(1000);
printf("hello mingw!\n");
// return 0;
}
_beginthread(input, 0, NULL);
getchar();
return 0;
}
...$ x86_64-w64-mingw32-gcc -o example.exe example.c
In a native Win7 box it works as expected:
...$ example.exe
hello mingw! (after 1 second)
a
...$
but in wine when entering 'a' from keyboard, the 'a' climbs up one line:
...$ example.exe
aello mingw!
...$
It seems as if printf output from a thread didn't update console cursor. This only happens when read code (getchar()) executes first than write code (printf),
hence the Sleep
Any pointers? Francesc