RE:segm. violation <-> iostream.h

Masaharu Goto (MXJ02154@nifty.ne.jp)
Fri, 16 Jul 1999 21:51:50 +0900


Hello Steve,

I think this is a famous iostream loading problem. Unfortunately, this
happens if you load iostream afterwards. Problem occurs after you reset
the dictionary somehow. Solution is to always load iostream at the
beginning of ROOT session. The latest ROOT does this automatically
I think. If you use old ROOT version, you can load it in rootlogon.C
as follows.

{
G__loadfile("iostream");
}

iostream is a very special library which implementation is sligtly
different from other library. This is the only generic solution.

Thank you
Masaharu Goto

=======================================================================
Hi rooters,

A segmentation fault appeared when I tried to run a macro a second time
(it is attached below). But if I include iostream.h directly on the
command line before executing the macro the first time, the segmentation
violation doesn't come afterwards.

Does anybody know why ?

Steve

PS : > Many thanks to Masaharu for the many answers on the limitation
problem

#include <iostream.h>
#include <fstream.h>

error() {

ifstream file("data.dat", ios::in);

gROOT->Reset();
c1 = new TCanvas("c1", "error",700,500);
c1.SetFillColor(0);
c1.SetGridx();
c1.SetGridy();

const int MAX = 2000;
float dose[MAX], voltage[MAX];
int count = -1;
while (!file.eof()) {
++count;
file >> dose[count] >> voltage[count];
}

gr = new TGraph(count, dose, voltage);
gr.SetMarkerColor(4);
gr.Draw("ACP");
c1.Update();
gr.GetHistogram().SetXTitle("dose / rad");
gr.GetHistogram().SetYTitle("voltage / mV");

return(0);
}