Subj : Re: reentrant fwrite/fputc/etc ? To : borland.public.cpp.borlandcpp From : gary Date : Fri Nov 14 2003 12:59 pm i think maybe i didn't ask the question clearly enough, or perhaps you misunderstood what is meant by "reentrant". there is no such thing as a function that is reentrant "some of the time". it is possible, i grant, to describe a function as being "reentered" some of the time, as the condition is obviously dependent on the totality of the code and what is happening within threads/ISRs. however, a function is either "reentrant" or it is "non-reentrant", meaning that it does or doesn't support being "reentered" without the second call screwing up what the first call was in the middle of doing. for example, if you put a printf() or fwrite() call in an ISR, you are going to find yourself in trouble eventually. the fact that it doesn't crash in the lab does not mean that it isn't going to crash in the field. some C lib functions aren't even technically compatible with each other for the silly reason that they set the global "errno" variable on error. so if your program is in the middle of a C lib call that has just set errno, but an ISR occurs before it can return and that ISR calls another C lib function that happens to set errno, upon return your main-line C lib function is going to appear to have set a different errno than it really did, which might well at some point make your program respond incorrectly to an error condition. this is why you need to be careful what C lib functions you call inside an ISR. in my case, the question was just about C lib functions that disturb the operation of other instances of themselves. for example, those that use static buffers (like strtok(), etc) and those that use global buffers (like the _iob[] structures used by stream i/o functions). Andrue Cope wrote: > Gary, > > >>does anyone know >>if Borland (or Microsoft or any other compiler vendor) bothers to >>publish such a list for their C libraries? >> >> > > I don't know that there would be such a list. It may be that some of > the functions just happen to be reentrant some of the time. > -- > Andrue Cope > [Bicester, UK] > > .