printf re-entrant?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

printf re-entrant?

865 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wortel on Wed Feb 09 01:15:22 MST 2011
Since I will be using FreeRtOS and want to make use of these functions, I need to know if printf / sprintf are re-entrant. Else I will have to make an gatekeeper or something alike.
0 Kudos
Reply
2 Replies

851 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by SOTA on Mon May 16 15:30:01 MST 2011
This something i've just tried with the LPC1343 - under freertos, redlibw/semihosting, and integer only printf - seems to work fine for the first 3 lines output, and the causes a hardfault while in the middle of printing out a differnt string ... EDIT : source found: DOH! forgot to allocate extra stack space for printf() !
So it works fine :)
0 Kudos
Reply

851 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Wed Feb 09 07:31:36 MST 2011
From a quick scan of the code, everything looks like it should work ok. But whether this is a sensible thing to do is a different matter. Semihosting in a interrupt driven environment is not likely to work too well, as the CPU will get stopped each time a string is output. More info at:

http://support.code-red-tech.com/CodeRedWiki/UsingPrintf

Regards,
CodeRedSupport
0 Kudos
Reply