I work on a well-established, embedded C++ code base. We have been using a propr
ID: 653079 • Letter: I
Question
I work on a well-established, embedded C++ code base. We have been using a proprietary API to our filesystem. For better integration with third-party C libraries, we are currently in the process of implementing most of stdio.h and fcntl.h. I made what I thought was a non-controversial proposal that we should also implement the fstream class and encourage new C++ code to use it instead of the new (to our code base) C-style API. We already have the stdout parts of iostream available, although it is not widely used.
Given a choice between using stdio and fstream, what are good reasons to choose stdio for embedded software development in C++?
Explanation / Answer
My top reason would be familiarity with the library. Back in my embedded days (a little over a decade ago), most C++ developers in several companies where I worked came from a strong C background. C-style input and output did not require any learning, while dealing with advanced concepts of manipulating streams often required checking a book.
As far as purely technical reasons go, I don't think there are any: properly implemented stream I/O should be as fast as the C-style I/O, and use roughly the same amount of memory.