problem w/ mingw32/egcs/msvcrt and file reads

Paul Thiessen paul@grserv.med.jhmi.edu
Fri May 7 16:19:00 GMT 1999


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 <iostream>
#include <fstream>
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@grserv.med.jhmi.edu | Johns Hopkins
 Thiessen | http://grserv.med.jhmi.edu/~paul | University
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /