Re:C Portability Lessons from Weird Machines
by asveikau on Thursday November 15, 2018 @11:34PM
(#18466444)
What you write about I/O is interesting to me, because I am generally of the belief that any decent library in C should have a way to replace I/O with an alternate mechanism via a couple of function pointers.
Even if you stick to recent platforms, depending totally on FILE* can be a mistake. For example Windows has all its idiosyncrasies with sharing modes and whatnot, not all of them captured by fopen. Or you may wish to implement streaming or some alternate data source not on the filesystem. The author of a library can't predict these things, so should allow the caller to bring their own.
Even if you stick to recent platforms, depending totally on FILE* can be a mistake. For example Windows has all its idiosyncrasies with sharing modes and whatnot, not all of them captured by fopen. Or you may wish to implement streaming or some alternate data source not on the filesystem. The author of a library can't predict these things, so should allow the caller to bring their own.