Re: CINT Q: parsing type definitions on the fly

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Jun 17 1997 - 17:49:17 MEST


Pasha Murat wrote:
> 
>         Hi,
> 
>         I have a question about rootcint parsing a type definition
>         (I'm using SGI IRIX 5.3, GCC-compiled ROOT 1.01/03):
> --------------------------------------------------------------------------------
> -1-
> 
>         I have a problem when trying to define a new type interactively:
> 
> CINT/ROOT C/C++ Interpreter version 5.13.10, May 22 1997
> Type ? for help. Commands must be C++ statements.
> Enclose multiple statements between { }.
> root [0] struct AA {
> end with '}'> int ia;
> end with '}'> };
> root [1] AA a;
> root [2] a.ia = 10;
> 
>  *** Break *** segmentation violation
> --------------------------------------------------------------------------------
> -2-
> 
>         However the same type definition could be used without any problem
>         when loaded from a file:
> 
> -------------------------- test.cc
> struct AA {
>   int ia;
> };
> ---------------------------
> 
> root [0] .L test.cc
> root [1] AA a;
> root [2] a.ia = 10;
> root [3] .p a
> (struct AA)272045208
>   0x0        int ia=10
> 
> --------------------------------------------------------------------------------
> -3-
>         Finally, the following command sequence works:
> 
> root [13] typedef struct AA {
> end with '}'> int ia;
> end with '}'> };
> root [14] a.ia = 10;
> root [15] .p a
> (struct AA)272045208
>   0x0        int ia=10
> 
> --------------------------------------------------------------------------------
> 
>         The question is why interactive type definition does require
>         `typedef' whereas loading the same type definition from the macro
>         file does not?
> 

When you have multilines input, you should always start by a { and close with a }
The following will work:
{
  struct AA {
  int ia;
  };
}


Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:19 MET