WarpUp (9/42)

From:Tim Hanson
Date:13 Aug 2001 at 23:45:29
Subject:fstream and ppc-amigaos-g++

Hi All,

Firstly, please ignore my previous posting. The answer was RTFM. When
compiling c++ add -liostream to the command line. DOH!

I now have my project compiling ok but it fails on a read() from an opened
fstream object. I`ve done is_open() on the object and it is open but the
machine jams on the first read. On one occasion I got a warpcrash indicating
a load from memory 00000000. The code works fine under 68k so I suspect a
mistake in the command line options.

Any thoughts?

#include "map.h"
#include <stdlib.h>

extern void fail(char *errStr);

char idStr[]="MAP1";
char inBuf[]="DEAD";

Map::Map(fstream& in)
{
cout << in.is_open() << endl;
cout << "About to read" << endl;
in.read(inBuf,4L); <<<-------crashes here.
cout << "Read" << endl;
for(int i=0;i<4;i++)
{
cout << inBuf[i] << endl;
if(inBuf[i]!=idStr[i])
fail("recognise file format");
}
}



any persons, living or dead, are entirely coincidental.
Tim Hanson,
by the River,Canterbury, Kent.
Amiga A1200T,`040/25,603e/160,32MB Fast,BVisionPPC,
8.4GB IDE HD,ZIP SCSI,RENO x2CD SCSI,Pace 56K