Hi,
my first trial with root is shown at the bottom.
I just want to read an external file. As shown below,
in interpreted mode it runs fine, but the compiler gives some unexpected message.
As I understand, some header file is missing, and it is not because of me.
root [0] .x mydemo.c
ReadFile: Si_1s_3000.dat contains 2520 lines
root [1] .x mydemo.c++
Warning in : script has already been loaded in interpreted mode
Warning in : unloading F:\root\tutorials\mydemo.c and compiling it
c.dllin TWinNTSystem::ACLiC: creating shared library F:\root\tutorials\mydemo_
s22o.1_cint.cxx
s22o.3_cint.cxx
s22o.5_cint.cxx
s22o.7_cint.cxx
s21s_.cxx
F:\root\tutorials\s21s_.h(7) : fatal error C1083: Cannot open include file: ‘std
def.h’: No such file or directory
Error in : Compilation failed!
Error: Function mydemo() is not defined in current scope FILE: LINE:0
Possible candidates are…
filename line:size busy function type and name
!!!Dictionary position not recovered because G__unloadfile() is used in a macro!
!!
*** Interpreter error recovered ***
root [2]
Also, when I comment out the #include, practically no change:
root [0] .x mydemo.c++
c.dllin TWinNTSystem::ACLiC: creating shared library F:\root\tutorials\mydemo_
s12c.1_cint.cxx
s12c.3_cint.cxx
s12c.5_cint.cxx
s12c.7_cint.cxx
s12o_.cxx
F:\root\tutorials\s12o_.h(7) : fatal error C1083: Cannot open include file: ‘std
def.h’: No such file or directory
Error in : Compilation failed!
Error: Function mydemo() is not defined in current scope FILE: LINE:0
Possible candidates are…
filename line:size busy function type and name
*** Interpreter error recovered ***
root [1]
On XP, with interpreter it runs fine, too.
If the #include is commented out, the linked does not find it, OK.
If it is present, the compiler issues error message on redefining
ifstream and ofstream.
Do I wrong something? What is the correct way to use an ifstream
in the compiled version?
Thanks
Janos
#if !defined(CINT)
#include <istream.h>
#endif
Double_t *x;
Double_t *y;
void ReadFile(const char *FileName)
{
Int_t Index = 0; char buf[500];
ifstream stream(FileName);
bool FD = false; // assume failure
do {stream.getline(buf,sizeof(buf)); ++Index;
}
while (!stream.eof()); --Index; //Count total# of lines
printf(“ReadFile: %s contains %d lines\n”,FileName, Index);
}
void mydemo()
{
TCanvas c1 = new TCanvas(“c1”,“A Simple Graph Example”,200,10,700,500);
ReadFile(“Si_1s_3000.dat”);
x = new Double_t[100];
y = new Double_t[100];
for(Int_t i=0; i<100; i++)
{
x[i] = i;
y[i] = ii;
}
TGraph G1 = new TGraph( 100, x, y);
G1->Draw("AC");
}