Re: gROOT->ProcessLine() problem

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Tue, 19 Apr 2011 19:15:15 -0500


Hi Tom,

To get the information about success or failure of an ACLiC compilation, you can call the ACLiC interface directly. I.e.:

    Int_t result = gSystem->CompileMacro("HistoRoot.C","k");     if ( ! result ) {

       // Something bad happened.
    }

 > Also: how can I suppress all the error messages from the  > compilation when it fails? (Users are not going to debug the code)

That is a bit more complex, as for now we let the compiler print its output directly. In order to avoid the out you would to use CINT's ability to redirect the stdout by doing something like:

    Long_t result = gROOT->ProcessLine("gSystem->CompileMacro(\"HistoRoot.C\",\"k\"); > compile.log ");     if ( ! result ) {

       // Something bad happened.
    }

Cheers,
Philippe.

On 4/18/11 4:11 PM, Tom Roberts wrote:
> BACKGROUND:
> I have written a large Root macro, HistoRoot.C, that runs both with and without ACLiC. I distribute it to many users, some of whom
> have a compiler, but most don't. This macro reads a large TNtuple almost 100 times faster when compiled, so compilation is highly
> desirable whenever possible. Until now it has been a macro only (it took a major effort to get it to compile and run via ACLiC).
>
> I am using Mac OS X 10.5.8 (Leopard), and Root 5.26 installed from binary (that's the most recent version for this OS). I also
> distribute for Linux and Windows.
>
>
> PROBLEM:
> gROOT->ProcessLineSync() does not return any error code.
>
> METHOD:
> I deliberately put a compilation error into HistoRoot.C, and ran
> root -l Bootstrap.C
> The Bootstrap macro (below) is intended to compile HistoRoot.C if possible, and to run it as a macro if not. But even though the
> compilation failed, the supposed error codes from ProcessLineSync() are the same as when compilation succeeds:
> err=0 retVal=0
>
> So how can I determine if compilation failed, WITHOUT user intervention?
>
> Also: how can I suppress all the error messages from the compilation when it fails? (Users are not going to debug the code)
>
>
> Tom Roberts
>
>
> ------ Bootstrap.C:
> // Bootstrap.C -- bootstrap HistoRoot
>
> void Bootstrap()
> {
> // the default optimization ".O 4" fails miserably in HistoRootWindow
> gROOT->ProcessLineSync(".O 3");
>
> Int_t err=0;
>
> // First, try to load HistoRoot.C via ACLiC
> Long_t retVal = gROOT->ProcessLineSync(".L HistoRoot.C+",&err);
> printf("err=%d retVal=%d\n",err,retVal);
>
> // here is where I would test the error codes and load the macro
>
> new HistoRootWindow(); // in HistoRoot.C
> }
>
>
> ------ HistoRoot.C:
> // HistoRoot.C
>
> force compile error
>
> // class HistoRootWindow has a constructor that displays a GUI window which
> // handles user input, opens Root files, generates plots, etc.
> // Omitted for brevity.
>
Received on Wed Apr 20 2011 - 02:15:21 CEST

This archive was generated by hypermail 2.2.0 : Wed Apr 20 2011 - 17:50:01 CEST