Re: [ROOT] About the size of struct in ROOT

From: Bengt Wessling (wessling@mail.desy.de)
Date: Wed Apr 02 2003 - 08:38:39 MEST


Hi Huang,

On Wed, 02 Apr 2003, Huang Xingtao wrote:

> For example:
>  void main() {
>  struct A{
>    unsigned int  a;
>    unsigned int  b;
>    short  int       c;
> };
> cout<<"Size of A:"<<sizeof(A)<<endl;
> }

looks like CINT aligns the structure on 16 bytes. You can force the 
compiler to do it differently with something like

struct A {
    unsigned int a;
    unsigned int b;
    short  int c;  
} __attribute__((packed));

or you can control the alignment of your structure or your structure
members with __attribute__((aligned(n))), n being a power of 2. But do
you really need that? Compilers usually align the data on purpose...

Bengt



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