RE: [ROOT] Several question: globals in aclic, circular dependencies in aclic, default webbrowser

From: Martijn Schellekens (Martijn.Schellekens@iota.u-psud.fr)
Date: Tue Feb 10 2004 - 09:35:47 MET


Thanks a lot Philippe, I will try this out,
Cheers,
Martijn

A 13:08 09/02/2004 -0600, Philippe Canal a écrit :
>Hi,
>
>You NEED to define gWorkspaceDirectory in compile code.
>This means do NOT define it in rootalias.C (at least not directly),
>and do NOT attempt to access it before loading it library.
>
>In the example you sent, I must be missing some code since I did not
>find a "pragma link C++ global gWorkspaceDirectory;"
>
>Anyway, this can be done very very simply.
>
>Create two (new?) files called global.h global.cpp containing:
>
>//global.h
>#ifndef HEADER_GLOBAL_H
>#define HEADER_GLOBAL_H
>#include "TString.h"
>R__EXTERN TString gWorkspaceDirectory;
>#endif HEADER_GLOBAL_H
>// end of global.h
>
>//global.cpp
>#include "global.h"
>TString gWorkspaceDirectory
>//end of global.cpp
>
>then add
>         #include "global.h"
>to your MTest.cxx
>
>Then use test.C as follow:
>{
>         gSystem->CompileMacro("global.cpp","k");
>         gWorkspaceDirectory="Hello world";
>         gSystem->CompileMacro("MTest.cxx","k");
>         MTest* sayhello=new MTest(); //should print "Hello world"
>}
>
>Cheers,
>Philippe.
>
>-----Original Message-----
>From: Martijn Schellekens [mailto:Martijn.Schellekens@iota.u-psud.fr]
>Sent: Monday, February 09, 2004 1:02 PM
>To: Philippe Canal; roottalk@pcroot.cern.ch
>Subject: RE: [ROOT] Several question: globals in aclic, circular
>dependencies in aclic, default webbrowser
>
>
>Thanks for your answers Philippe,
>Yet I stil dont understand what I am supposed to do exactly for the first
>point. I tried out what you proposed but I didn't get what I expected.
>I enclosed three files with this mail: could you show me what you would do
>exactly to make the script "Test.C" work?
>
>thanks a lot,
>
>Martijn
>
>
>A 11:29 09/02/2004 -0600, Philippe Canal a écrit :
> > > 1. Global variables: critical
> >
> > > I compiled the code (ie: MUtilities.cxx) using the R__EXTERN macro and
> > > compilation is fine
> >
> >Actually you should use R__EXTERN in an header file (for other compilation
> >unit) and 'declare' the global variable without the R__EXTERN in one of the
> >cxx file.
> >
> > > 2. Circular dependencies: important
> >
> >There is a couple of solutions.
> >In the following I assume that you have 4 files: file1.C file1.h, file2.C
> >and file2.h
> >You need to create a 5th file:
> >
> >// lib.C
> >#include "file1.C"
> >#include "file2.C"
> >// end of lib.C
> >
> >and use it:
> >    root [] .L lib.C+
> >    root [] .L file1.h+
> >    root [] .L file2.h+
> >
> >Or you can use a more elaborate lib.C file:
> >
> >// lib.C
> >#include "file1.C"
> >#include "file2.C"
> >#ifdef __CINT__
> >#pragma link C++ class myclass1+;
> >#pragma link C++ class myclass2+;
> >// and any other pragma statements that are needed
> >#endif
> >// end of lib.C
> >
> >and use it:
> >    root [] .L lib.C+
> >
> >
> > > 3. Default Webbrowser: enhancement
> >
> >We are working toward making the THtml documentation available at run-time.
> >
> >Cheers
> >Philippe
> >
> >-----Original Message-----
> >From: owner-roottalk@pcroot.cern.ch
> >[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Martijn Schellekens
> >Sent: Monday, February 09, 2004 8:05 AM
> >To: roottalk@pcroot.cern.ch
> >Subject: [ROOT] Several question: globals in aclic, circular
> >dependencies in aclic, default webbrowser
> >
> >
> >Hi Rooters,
> >
> >I encoutered three problems this weekend, and I desperately need some help.
> >
> >1. Global variables: critical
> >
> >I tried to compile several scripts this weekend that used global variables.
> >The global variable was for example a TString gWorkspaceDirectory that does
> >exist in my
> >gROOT according to GetListOfGlobals() (it is defined in my rootalias.C)
> >I compiled the code (ie: MUtilities.cxx) using the R__EXTERN macro and
> >compilation is fine
> >(as a matter of fact i use ACLiC)
> >I created the header MUtilities_linkdef.h that is detected and integrated
> >by the compilation
> >procedure as gDebug=6 tells me
> >I wrote #pragma link C++ global gWorkspaceDirectory in my linkdef file.
> >Yet once the script is loading it returns it can not identify
> >gWorkspaceDirectory.
> >What do I wrong or where can I find documentation that explains simply what
> >to do?
> >
> >
> >2. Circular dependencies: important
> >
> >I have two source files that are strongly related. The header files are
> >sufficient for
> >compiling yet once compiled with ACLiC they can not be loaded as they
> >depend on each other
> >and they can not be loaded simultaneously. Is there a simple way using
> >ACLiC to compiling
> >and loading those interdependent source files?
> >
> >
> >3. Default Webbrowser: enhancement
> >
> >Documentation related to my userinterface is in html (by the way thanks for
> >the excellent
> >THtml class) and it would be nice for the users to simply press on a button
> >so it opens. Is
> >there a methos within root that could return the default internet browser
> >(on both linux,
> >windows and macOS)?
> >
> >
> >I thanks in advance anybody that could help me on any of those questions.
> >
> >Martijn Schellekens



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET