[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-ocrad] OCRAD with Visual Studio 2010 success
From: |
Antonio Diaz Diaz |
Subject: |
Re: [Bug-ocrad] OCRAD with Visual Studio 2010 success |
Date: |
Wed, 11 Aug 2010 17:51:01 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.7.11) Gecko/20050905 |
Tilman Hausherr wrote:
I can't, because both STDIN_FILENO and __MSVCRT__ don't exist, at least
not here in VS2010.
OK. Maybe the following code works:
#if defined(__MSVCRT__) || defined(_MSC_VER) || defined(__OS2__)
setmode( fileno( stdin ), O_BINARY );
setmode( fileno( stdout ), O_BINARY );
#endif
if( ( control.outfile = std::fopen( outfile_name, "wx" ) ) == 0 )
I have to think about this because removing the 'x' breaks --force.
(Files are always overwritten). Isn't there an equivalent to O_EXCL for
streams?
No, not in Visual C++ 2010, sadly.
Using _access introduces an unavoidable race condition between the call
to _access and the call to fopen. See
https://www.securecoding.cert.org/confluence/display/seccode/FIO10-C.+Take+care+when+using+the+rename%28%29+function
And given that the 'x' mode has been added to the C1X standard, probably
the best option is you patch it until Visual C++ 201X implements it. See
http://webcache.googleusercontent.com/search?q=cache:d8BBqkWymaYJ:https://www.securecoding.cert.org/confluence/download/attachments/26017980/WG14March2009%2Bv3.pdf?version%3D1%26modificationDate%3D1239645959000+%2Bfopen+%2BO_EXCL+%2BC1X&hl=en&gl=es
page 9.
Details of a benchmark that I just did, this time without a supervising
application:
time with gcc + cygwin: 39 secs
time with VC++ 2010 32 bit: 16 secs
time with VC++ 2010 64 bit: 12 secs
Impressive numbers! Some Cygwin expert should check this.
Regards,
Antonio.
Re: [Bug-ocrad] OCRAD with Visual Studio 2010 success, Tilman Hausherr, 2010/08/10