Is it allowed to mix different file handling functions in a one system e.g.
- fopen() from cstdio
- open() from fstream
- CreateFile from Win API ?
I have a large application with a lot of legacy code and it seems that all three methods are used within this code. What are potential risks and side effects ?
Yes, you can mix all of that together. It all boils down to the CreateFile call in any case.
Of course, you can’t pass a file pointer to
CloseHandleand expect it to work, nor can you expect a handle opened fromCreateFileto work withfclose.Think of it exactly the same way you think of
malloc/freevsnew/deletein C++. Perfectly okay to use concurrently so long as you don’t mix them.