This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: printf() and _write() in newlib-nano
- From: Craig Howland <howland at LGSInnovations dot com>
- To: <newlib at sourceware dot org>
- Date: Wed, 19 Apr 2017 11:17:00 -0400
- Subject: Re: printf() and _write() in newlib-nano
- Authentication-results: sourceware.org; auth=none
- References: <02d116cb-f9a6-8f0c-8ab2-8dda8cec8f37@powersoft.it>
On 04/19/2017 04:55 AM, massimiliano cialdi wrote:
I use newlib-nano in an embedded project.
I have implemented my version of _write() to make printf() output chars to UART.
I wonder if a single call of printf() results in a single call of _write(),
or, otherwise _write() can be called more than once by printf().
best regards
Max
It depends on many factors (the actual print string, buffered, line buffered,
text mode, etc.), but either alternative can happen--either one _write per print
or more than one. It can range from one write per print to one per character.
If it is important to you, it probably would be best to instrument it to find
out directly, and you could observe how it varies.