Reading too few bytes

Larry Hall (Cygwin) reply-to-list-only-lh@cygwin.com
Wed Mar 22 05:18:00 GMT 2006


Paul J. Lucas wrote:
> Here's a small test program:
> 
> 	#include <fcntl.h>
> 	#include <cstdlib>
> 	#include <iostream>
> 	
> 	using namespace std;
> 	
> 	int main() {
> 	    int fd = ::open( "ESLF", O_RDONLY );
> 	    if ( fd == -1 ) {
> 	        cerr << "could not open ESLF file" << endl;
> 	        ::exit( 1 );
> 	    }
> 	    char buf[ 64 ];
> 	    ssize_t bytesRead = ::read( fd, buf, sizeof( buf ) );
> 	    cout << "read " << bytesRead << " bytes" << endl;
> 	    ::close( fd );
> 	}
> 
> Here's the contents of a small biinary file "ESLF" (printed in hex bytes):
> 
> 	54 39 CA 1A 44
> 
> When I compile the program as:
> 
> 	g++ -o test test.cpp
> 
> and run it, it prints "read 5 bytes" as one would expect.  When I compile
> the program as:
> 
> 	g++ -mno-cygwin -o test test.cpp
> 
> and run it, it prints "read 3 bytes".  Why?  How do I teg it to read all
> 5 bytes?

Ask the MinGW llist, since -mno-cygwin simply enables you to run their
compiler "indirectly".  As a result, questions about the MinGW compiler
are off-topic for this list, since it's not Cygwin.
See <http://mingw.org/>.

-- 
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list