[Box Backup] Workaround for struct packing problem on ARM processors (was: Another wish for 2011)

Leif Linderstam ell2 at live.se
Sat Feb 26 13:47:08 GMT 2011


Hi Chris,

Another thing I just came to think of. If you want to check the size of the
structs that form the network protocol there is a nice tool in the Boost
library, the static assert:

  http://www.boost.org/doc/libs/1_46_0/doc/html/boost_staticassert.html

It can be used as follows:

  typedef struct
  {
        int64_t mDependsNewer;
        int64_t mDependsOlder;
  } en_StreamFormatDepends;
  
  BOOST_STATIC_ASSERT(sizeof(en_StreamFormatDepends) == 16);

This will generate a compilation error if the size of the struct is not 16,
which is as early warning as you can get. (Well, actually it is not really
just a warning as it will not compile if the size is wrong.)

Cheers,
Leif

 		 	   		  


More information about the Boxbackup mailing list