I have a large code which was earlier built for Linux environment, which involves call to write() from unistd.h. Is there any port of write() call available for Win32 en开发者_如何学JAVAvironment. I am looking to build this large code base 'as it is' on Windows environment(MS-VS 2005 enviroment) without touching the code if possible.
Changing the code to replace the write() calls with fwrite() would be tedious manual process as the signatures of the two are different.
EDITED: Actually many other unix based calls fail as well in Windows environment as well - read(),open(),close()...
Any pointers would be useful.
thank you.
-AD
Microsoft's C runtime has _open
_read
_write
etc. as "low-level I/O". However, these are compatibility wrappers mangled managed by the C runtime layer and subject to restrictions like "limited by _getmaxstdio
and can't go higher than 2048".
You can use the NT native CreateFile
ReadFile
WriteFile
for true low-level I/O.
I'd be a little surprised if they didn't work, but if they don't, your best bet is to write a little porting layer library that implements them using Win32API calls.
This would undeniably be quicker than doing search and replace on a lot of code and also mean that your main code base remains unchanged and portable.
精彩评论