I have some code which runs on Linux and Windows which I'm currently porting to macOS. One sticking point is fwrite_unlocked
(Linux), which has an equivalent on Windows (_fwrite_nolock
), but not on macOS, as far as I can see. For now I'm just using fwrite
, but I'm wondering if there is a better solution ? Will this just result in a performance hit, or am I risking more serious problems if I use fwrite
for this ?
From that man page, fwrite_unlocked
is just like fwrite
but less safe. So, there's no risk of "more serious problems" from using fwrite
. It does seem likely that fwrite
will be less performant; the whole purpose for the _unlocked
functions is to be faster.
Note this from the man page:
[The nonstandard *_unlocked() variants] should probably not be used.