This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

printf not working, if buffering disabled


Hi,

i've wrote a small program using newlib's printf funktion. All works
well as long as buffering is enabled. If I disable buffering using the
following code

setvbuf(stdout, NULL, _IONBF, 0);

the printf functions are not working anymore, while a call to putchar
produces the expected result.

The code looks like this

#include <stdio.h>

void
main (void) {
	/* init USB CDC device */
	usbcdc_init();

	//setvbuf(stdout, NULL, _IONBF, 0);
	putchar('y');
	putchar('\n');
	iprintf("test\n"); /* <- not working if buffering disabled */

	while (1);
}

The _write syscall is implemented as

int _write(int file, char *ptr, int len) {
	while (len--) {
		if (*ptr == '\n') {
			usbcdc_putch('\r');
		}
	}
	return len;
}

Anybody an idea?

Regards,

Marc


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]