Re: printf() stops working after some time
Josef Wolf <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
No opinions on this one? On Fri, Oct 19, 2018 at 12:19:57PM +0200, Josef Wolf wrote: > Hello, > > I am using newlib (and its printf) for more than 15 years now. > > Now I upgraded to 3.0.0 and see that printf() stops working once write() > returns an error. Looks like printf() sets an error flag on the stream which > needs to be cleared by clearerr(). > > Unfortunaltey, GCC optimizes printf calls with constant format strings to use > puts() instead of printf. And puts() does NOT honor this error flag. > > The result is that, once write() returns an error, only those optimized > printf() 'calls' will be output. > > Why are printf/puts inconsisten on the error handling? > > Is there a way to "auto-clear" this error flag? > > I have not seen this in older newlib releases. > > > PS: As I investigated the above issue, I've seen that printf() and friends are > using malloc/realloc and things. I'm getting pretty nervous about malloc > usage, since this is an embedded system which is supposed to run for > really long term (years/decades) and fragmentation would be a major issue. > > Is it possible to disable malloc usage when compiling newlib? > > -- > Josef Wolf > [email protected] -- Josef Wolf [email protected]