delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/05/07/19:21:14

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 <paul AT grserv DOT med DOT jhmi DOT edu>
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: <Pine.SGI.4.10.9905071909370.67093-100000@turandot.med.jhmi.edu>
MIME-Version: 1.0

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 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019