1

I've the following code:

#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;
}

I cross-compile from ubuntu 22.04.01 with mingw-w64 with:

...$ 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 before the write code (printf), hence the Sleep.

Any pointers?

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
francesc
  • 343
  • 3
  • 12

0 Answers0