RE: [ROOT] how does Cint handle inline function ?

From: Faine, Valeri (fine@bnl.gov)
Date: Sun Mar 02 2003 - 04:24:27 MET


> Suppose we have B.H file such as:
> 
> // B.H
> class A;
> 
> class B {
> public:
>    B(){};
>    ~B(){};
> 
>    inline bool foo() /* code */
>    { process_object_of_A; return true; };
> }
> // ---------------implementation of B is compiled into a shared lib.
> 
> Suppose in B_LinkDef.H,
> we have
> #pragma link C++ class B-;
> 
> // -------------------------
> 
> Now, let's say we have a block of C++ code:
> {
>    ...
>    B b();
> 
>    /* *** */
>    b.foo();
> }
> 
> For compiled codes,  gcc will insert the binary
> for /* code */ at the place /* *** */.
> 
> Suppose the same block is submitted to Cint,
> how is b.foo() carried out ?

  What do you mean "submitted" to Cint?


> I'd guess that Cint traslates b.foo() into a
> 'function call' that calls the binary of /* code */
> stored in the shared library.
> 
> Do I understand this correctly ?

Not exactly. Cint is not a C++ "translator". By this reason it can not
"translate" things. CINT is an interpreter. 

My guess Cint should not pay any attention (and it can not) to whether
the method is "in-lined" (Masa may corrrect if I am wrong)
The method will be "in-lined" during the normal compilation of RootCint
dictionary by the native compiler if any.

The later means (very roughly):

1. Your "B.H" is to be "submitted" to the RootCint utility.
2. That will WRITE the C++ code - "dictionary".
3. That code is to be COMPILED by the native compiler, and the call to
your method is to be "inlined" as usually, and the dictionary share
library is to be created (Again the call to your method has been
"in-lined" by the normal compiler)
4. You start your ROOT session
5. Load your dictionary share library
6. TYPE the C++ statement "b.foo();".
    6.2. CINT parses your statement.
    6.3. It finds the dictionary entry to implement "b.foo()" method
    6.4. Cint calls the dictionary method from the share library
    6.5. The "dictionary method" calls your "in-lined" method prepared
by the native compiler

I would advice the Web site:

http://www.idiom.com/free-compilers/

for further information.
  

  Hope this helps, Valeri


> 
> thanks,
> HP



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET