I am working on a project related to Systems Programming on Windows. For that I was pointed toward windows.h
. Now I have come across io.h
. What exactly is the difference between them?
For example, since I am porting an application that has already been deployed on Linux, the file open function is open
while on Windows, if I use windows.h
, the file open function will be CreateFile, and if I use io.h
, it will be _open().
io.h
originally provided access to declarations for the low-level I/O primitives in Unix and associated constants and such. Since quite a bit of code depended on it, many (most?) compilers for other systems provided a header by the same name, and some library functions that worked (at least mostly) like the ones in Unix.
Windows.h is (sort of) a rough analog for Windows--a header that gives access to (declarations for) the functions, constants, etc. for Windows. The big difference is that Windows.h does a lot more than the basic, low-level I/O covered by io.h
, instead covering all the GUI functions, etc.
So: if you want to write code that does I/O at a fairly low level on Unix-like systems and can also port to other systems like Windows, you probably want to use io.h
. If you want to do system programming specifically for Windows, you almost certainly want to use windows.h
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With