Hi, The argument to ProcessLine is a string, so gROOT->ProcessLine(run(infile,outfile)); is an illegal statement. You should do simply run(infile,outfile); or convert this into a string, eg char cmd[50] sprintf(cmd,"run(\"%s\",\"%s\")",infile,outfile); gROOT->ProcessLine(cmd); Rene Brun Burair Kothari wrote: > > Hi, > > Using root: > > D0 version: Product=root Version=v3_05_00b Flavor=Linux+2.4 > Qualifiers="KCC_4_0:exception:opt:thread" > > same thing on a node running Debian Linux with root v4 > > Of these two macros one works while the other dosent: > ======================================================================== > This dosent work: > > //----------------------------------------------------------------------- > // commandline.C > //----------------------------------------------------------------------- > void commandline(const char * infile = "hello" ,const char * outfile = > "world") > { > > gROOT->ProcessLine(".L run.C+"); > gROOT->ProcessLine(run(infile,outfile)); > // gROOT->ProcessLine(".x run.C++(infile,outfile)"); > > } > > //----------------------------------------------------------------------- > // run.C > //----------------------------------------------------------------------- > #include <iostream> > > using namespace std; > > int run(const char * infile, const char * outfile) > { > cout << " " << infile > << " " << outfile << endl; > > return 0; > } > > ========================================================================= > # root -b -l -q -n 'commandline.C("Ernest","Rutherford")' > > Produces > on stdout: > Processing commandline.C("Ernest","Rutherford")... > Ernest Rutherford > > and on stderr: > > *** Break *** segmentation violation > Generating stack trace... > 0x4017b291 in TUnixSystem::StackTrace(void) at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/unix/src/TUnixSystem.cxx:1358 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCore.so > 0x4017a600 in TUnixSystem::DispatchSignals(ESignals) at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/unix/src/TUnixSystem.cxx:583 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCore.so > 0x40177c2a in <unknown> from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCore.so > 0x40177caa in <unknown> from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCore.so > 0x009bf0b8 in <unknown> from /lib/tls/libpthread.so.0 > 0x400e06e0 in TROOT::ProcessLine(char const *, int *) at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/base/src/TROOT.cxx:1399 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCore.so > 0x4021c8e8 in <unknown> from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCore.so > 0x404f1a18 in G__ExceptionWrapper at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/Api.cxx:415 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x4047f3b1 in G__call_cppfunc at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/newlink.c:505 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x4046d718 in G__interpret_func at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/ifunc.c:6292 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x40450a5f in G__getfunction at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/func.c:1674 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x404eb676 in G__getstructmem at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/var.c:4862 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x404e4503 in G__getvariable at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/var.c:3538 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x40447bd8 in G__getitem at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/expr.c:1925 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x40445de7 in G__getexpr at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/expr.c:1389 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x404986ab in G__exec_function at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/parse.c:520 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x404a02a2 in G__exec_statement at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/parse.c:4399 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x4046ef6d in G__interpret_func at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/ifunc.c:7168 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x404512c1 in G__getfunction at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/func.c:1977 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x40447c0a in G__getitem at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/expr.c:1929 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x40445de7 in G__getexpr at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/expr.c:1389 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x4043c942 in G__calc_internal at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/expr.c:173 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x404a664b in G__process_cmd at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/cint/src/pause.c:2566 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCint.so > 0x40126a3e in TCint::ProcessLine(char const *, TInterpreter::EErrorCode *) at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/meta/src/TCint.cxx:264 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCore.so > 0x40126b5b in TCint::ProcessLineSynch(char const *, TInterpreter::EErrorCode *) at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/meta/src/TCint.cxx:307 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCore.so > 0x4009493b in TApplication::ProcessFile(char const *, int *) at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/base/src/TApplication.cxx:747 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCore.so > 0x40093e65 in TApplication::ProcessLine(char const *, bool, int *) at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/base/src/TApplication.cxx:631 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libCore.so > 0x40a645f2 in TRint::Run(bool) at /cdf/scratch/jeffk/root_cutting/KCC_4_0-opt-thread-exception/root/rint/src/TRint.cxx:225 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/lib/libRint.so > 0x080488ae in TRint::__ct(char const *, int *, char **, void *, int, bool) + 0x26e from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/bin/root.exe > 0x0073f770 in __libc_start_main + 0xf0 from /lib/tls/libc.so.6 > 0x080486c1 in __cxa_finalize + 0x41 from /D0/ups/root/Linux-2-4/v3_05_00bKCC_4_0-exception-opt-thread/bin/root.exe > Function commandline() busy flag cleared > > ============================================================================== > if I comment out the first two lines in the macro and uncomment the third > then it runs without the segmentation violation: > > //----------------------------------------------------------------------- > // commandline.C > //----------------------------------------------------------------------- > void commandline(const char * infile = "hello" ,const char * outfile = > "world") > { > > // gROOT->ProcessLine(".L run.C+"); > // gROOT->ProcessLine(run(infile,outfile)); > gROOT->ProcessLine(".x run.C++(infile,outfile)"); > > } > > what am I doing wrong? > > Thanks, > Burair
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET