RE:Sizeof question

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Wed Jan 20 1999 - 12:07:09 MET


Michal,

As you observed, size of struct/class is different between compiled and
interpreted classes. The reason is simply because the interpreter and
compiler have different member alignment rule. For compiled class,
the dictionary generator mirrors the byte alignment of the compiler.
But for an interpreted class, the interpreter uses original byte
alignment rule. 
If this is a problem, you need to precompile your struct/class definition
by rootcint or makecint.

I'll add this QA to the cint FAQ list.

Masaharu Goto

---------------------------------------------------------------------
  Below are two short programs illustrating my question.
  The first program when compiled with gcc under SunOS5.5
  returns 12 for the size of the structure, what I expect.

void main()

{
    struct  test_struct {
        float  a;
        float  b;
        float  c;
    }  test;

    printf(" size of test_struct  %d\n", sizeof(struct test_struct));
}

The ROOT version of the first program

void  Test_sizeof()

{
    struct  test_struct {
        Float_t  a;
        Float_t  b;
        Float_t  c;
    }  test;

    printf(" size of test_struct  %d\n", sizeof(struct test_struct));
}
 returns 16.

 Why is that?

 Thanks and regards.

 Michal Lijowski



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