Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Date: Fri, 7 May 1999 19:19:26 -0400 From: Paul Thiessen X-Sender: paul AT turandot DOT med DOT jhmi DOT edu To: cygwin AT sourceware DOT cygnus DOT com Subject: problem w/ mingw32/egcs/msvcrt and file reads Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII I'm trying to write a program that includes a simple routine to read a text file line by line. The following code works fine using the latest mingw32/egcs, without the msvcrt40-runtime stuff installed, but when I use the msvcrt40 stuff, I get a general protection fault at the first call to getline (in the while loop). I also notice that in an objdump -p of the resulting executable (with msvcrt-runtime installed), crtdll.dll is still being linked in. I thought that's what the msvcrt-runtime was trying to avoid? Any ideas why this is happening? I imagine I'm just doing something dumb, but I've been staring at this for hours and can't figure it out. Thanks! #include #include int PDBFile::readFile(const string &fileName) { ifstream in(fileName.data(),ios::in|ios::nocreate); if (!in || !in.is_open()) { cerr << "Couldn't open file " << fileName << '\n'; return PROBLEM; } else cout << "Reading " << fileName << '\n'; char line[MaxLineLen]; while (in.getline(line,MaxLineLen) && !(in.eof() || in.fail())) { ; // do stuff w/ lines here } if (!in.eof()) { cerr << "Problem reading " << fileName << ", possibly a line too long\n"; return PROBLEM; } return OKAY; } - Paul -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Paul A. | paul AT grserv DOT med DOT jhmi DOT edu | Johns Hopkins Thiessen | http://grserv.med.jhmi.edu/~paul | University -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com