Citeren Ram Chandra Jangir <[email protected]>:

Hi,

Did anyone observed stdout and putchar() behavior differences between musl &
uClibc?

I have below code snippet :

int main(void){
        int c;
        while((c=getchar())!= 'e')     {
                putchar(c+1);
        }
        return 0;
}

When I use uClibc/gcc, I can see writing c+1 from putchar() happening
immediately. But when I use musl, character(c+1) gets printed on console
only if I exit from the program by entering 'e'.
I guess printing character using putchar family on stdio is having bug(or
different implementation) in musl. Has anybody faced this issue? Any
workaround?

Apparently in uClibc stdout is unbuffered and in musl it is buffered. Either is allowed in the C-standard (it is not specified) so this is not a bug. If you want each character to be output immediately, you probably need to add flush(stdout).
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to