problem w/ mingw32/egcs/msvcrt and file reads

Paul Thiessen
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
  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.

#include <iostream>
#include <fstream>

int PDBFile::readFile(const string &fileName) {

  ifstream in(,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() || {
    ;  // do stuff w/ lines here
  if (!in.eof()) {
    cerr << "Problem reading " << fileName << ", possibly a line too
    return PROBLEM;

  return OKAY;

 - Paul

  Paul A.   |      |  Johns Hopkins
 Thiessen   |  |   University

Want to unsubscribe from this list?
Send a message to

More information about the Cygwin mailing list