Re: Syntax Error and I can't find it

From: John Idarraga <idarraga_at_cern.ch>
Date: Tue, 30 Mar 2010 12:54:20 -0400


Hello Cedric,

Ok, you didn't mention that you are doing

void auswertung( ){ .... }

in that case you are running your code within a context that won't hold your objects once the end is reached. Rene got you answer. This is not CINT fault. Nothing to do with the fact that you are returning void.

cheers !

John

On Tue, 2010-03-30 at 18:41 +0200, Rene Brun wrote:
> OK, this is very basic C++.
> When your function goes out of scope your TCanvas object is deleted. Use
> new instead.
> Same remark for TGraphErrors.
>
> Rene Brun
>
>
>
> Rene Brun
>
> Cedric Sodhi wrote:
> > Hi Phillippe, no its not a missing declaration or definition of Kalib1
> > - I dropped the line by accident and when I wanted to send out a
> > correction you had already beaten me to it.
> >
> > However, wrapping the whole thing in a void fixed the error. Great,
> > thank you CINT for such meaningful error messsages.
> >
> > Nonetheless wrapping it in a void had some other negative sideeffects:
> > Whereas before a canvas poppep up upon creating it, now nothing happens,
> >
> > not even on Kalib1.Draw( ). THe corrected source code (no lines
> > dropped) here:
> >
> >
> > #include "/home/manday/Programs/lib/raupach/praktlib.h"
> >
> > void auswertung( ) {
> >
> > gROOT->SetStyle("Plain");
> > string baseDir = "/home/manday/Documents/University/Physik
> > Praktikum/Akustik/Cassy/";
> > gStyle->SetOptFit();
> >
> > TCanvas gCWegKalib1( "WegKalibration","Kalibration Wegaufnehmer" );
> >
> > // Linearer Fit Wegaufnehmer
> > gCWegKalib1.SetGrid();
> > gCWegKalib1.SetFillColor( kWhite );
> >
> > PraktLib *gDatKalib1 = new PraktLib( baseDir +
> > "Kalibrierung.lab","cassy" );
> > const int gDatKalibLen = gDatKalib1->NumRows();
> >
> > Double_t* Kalib1R = new Double_t[ gDatKalibLen ];
> > Double_t* Kalib1S = new Double_t[ gDatKalibLen ];
> > for( int i = 0; i<gDatKalibLen; i++ ) {
> > Kalib1R[ i ]= gDatKalib1->ReadData( i,3 );
> > Kalib1S[ i ]= gDatKalib1->ReadData( i,4 );
> > }
> >
> > TGraphErrors Kalib1( gDatKalibLen,Kalib1R,Kalib1S );
> > // Kalib1.Fit( "pol1","W" );
> > Kalib1.Draw( );
> >
> > }
> >
> > Philippe Canal wrote:
> >> Hi Cedric,
> >>
> >> To get better error message you can ask the compiler by replacing:
> >>
> >> root [0] #include "auswertung.cpp"
> >>
> >> with
> >>
> >> root [0] #include "auswertung.cpp+"
> >>
> >> However you would need to turn this file in a proper C++ file (as
> >> oppose to using the CINT shortcuts).
> >>
> >> Nonetheless, it seems that the problem is with the line:
> >>
> >> Kalib1.Draw( );
> >>
> >> where Kalib1 is probably not properly defined.
> >>
> >> Cheers,
> >> Philippe.
> >>
> >> PS. The recommend way to use you script is:
> >>
> >> root [] .x auswertung.cpp
> >>
> >> and the best way to write it is:
> >>
> >> #include "/home/manday/Programs/lib/raupach/praktlib.h"
> >>
> >> void auswertung() {
> >> gROOT->SetStyle("Plain");
> >> string baseDir = "/home/manday/Documents/University/Physik
> >> Praktikum/Akustik/Cassy/";
> >> gStyle->SetOptFit();
> >>
> >> TCanvas gCWegKalib1( "WegKalibration","Kalibration Wegaufnehmer" );
> >>
> >> // Linearer Fit Wegaufnehmer
> >> gCWegKalib1.SetGrid();
> >> gCWegKalib1.SetFillColor( kWhite );
> >> PraktLib *gDatKalib1 = new PraktLib( baseDir +
> >> "Kalibrierung.lab","cassy" );
> >> const int gDatKalibLen = gDatKalib1->NumRows();
> >>
> >> Double_t* Kalib1R = new Double_t[ gDatKalibLen ];
> >> Double_t* Kalib1S = new Double_t[ gDatKalibLen ];
> >> for( int i = 0; i<gDatKalibLen; i++ ) {
> >> Kalib1R[ i ]= gDatKalib1->ReadData( i,3 );
> >> Kalib1S[ i ]= gDatKalib1->ReadData( i,4 );
> >> }
> >>
> >> Kalib1.Draw( );
> >> }
> >>
> >> On 3/30/10 11:07 AM, Cedric Sodhi wrote:
> >>> I'm sorry as I get the feeling that I seem to bombard the mailing
> >>> list with questions which appear trvial at best but CINT is driving
> >>> me in-sane! I don't consider myself a bad programmer, actually I
> >>> think I'm quite good at what I do although my last substancial
> >>> experience with CPP lies a few years behind but that CINThing is
> >>> getting the last iota of patience out of me. I got a deadline for
> >>> tomorrow and CINT stops me at the simplest tasks! Nothing seems to
> >>> work!
> >>>
> >>> Now, if anyone understand the following error message and can make
> >>> the link to the (few lines long) source code, please let me know, I
> >>> really need the help right now. The #included file in the #included
> >>> file can be found here, but shouldnt be the reason for this (it
> >>> better be not)
> >>>
> >>> >> If you are interested in trying this out you can find them packed
> >>> here:
> >>> >> http://accms04.physik.rwth-aachen.de/~praktapp/
> >>> <http://accms04.physik.rwth-aachen.de/%7Epraktapp/> -> "Neue ROOT
> >>> Routinen"
> >>> >> Direct link for download:
> >>> >> http://accms04.physik.rwth-aachen.de/~praktapp/root_new/
> >>> <http://accms04.physik.rwth-aachen.de/%7Epraktapp/root_new/>
> >>> >> Author(s) as mentioned on page.
> >>>
> >>> root [0] #include "auswertung.cpp" Converting
> >>> file to csv-file...
> >>> Starting conversion...
> >>> Opening output file: /home/manday/Documents/University/Physik
> >>> Praktikum/Akustik/Cassy/Kalibrierung.lab.out
> >>> Opening input file...
> >>> Checking file type by argument...
> >>> File type: CASSYLab file...
> >>> Looping over file...
> >>> Found 4 y columns...
> >>> Done!
> >>> Reading file /home/manday/Documents/University/Physik
> >>> Praktikum/Akustik/Cassy/Kalibrierung.lab.out...
> >>> Error: Missing one of ',)' expected at or after line 18.
> >>> Error: Unexpected end of file (G__fgetstream_template():2)
> >>> auswertung.cpp:26:
> >>> Error: Missing one of ',;{(' expected at or after line 26.
> >>> Error: Unexpected end of file (G__fgetstream_template():2)
> >>> auswertung.cpp:26:
> >>> Error: Missing one of '{' expected at or after line 26.
> >>> Error: Unexpected end of file (G__fignorestream():3) auswertung.cpp:26:
> >>> *** Interpreter error recovered ***
> >>> root [1]
> >>> ______________________
> >>>
> >>> #include "/home/manday/Programs/lib/raupach/praktlib.h"
> >>>
> >>> gROOT->SetStyle("Plain");
> >>> string baseDir = "/home/manday/Documents/University/Physik
> >>> Praktikum/Akustik/Cassy/";
> >>> gStyle->SetOptFit();
> >>>
> >>> TCanvas gCWegKalib1( "WegKalibration","Kalibration Wegaufnehmer" );
> >>>
> >>> // Linearer Fit Wegaufnehmer
> >>> gCWegKalib1.SetGrid();
> >>> gCWegKalib1.SetFillColor( kWhite );
> >>> PraktLib *gDatKalib1 = new PraktLib( baseDir +
> >>> "Kalibrierung.lab","cassy" );
> >>> const int gDatKalibLen = gDatKalib1->NumRows();
> >>>
> >>> Double_t* Kalib1R = new Double_t[ gDatKalibLen ];
> >>> Double_t* Kalib1S = new Double_t[ gDatKalibLen ];
> >>> for( int i = 0; i<gDatKalibLen; i++ ) {
> >>> Kalib1R[ i ]= gDatKalib1->ReadData( i,3 );
> >>> Kalib1S[ i ]= gDatKalib1->ReadData( i,4 );
> >>> }
> >>>
> >>> Kalib1.Draw( );
> >>>
> >>
> >
>
Received on Tue Mar 30 2010 - 18:48:04 CEST

This archive was generated by hypermail 2.2.0 : Wed Mar 31 2010 - 05:50:02 CEST