Re: printf() stops working after some time
Jie Zheng <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Oh that's sad to hear. On 10/19/18, 6:20 PM, "[email protected] on behalf of Josef Wolf" <[email protected] on behalf of [email protected]> 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]