we are practically using bit field in all on-disk structures, and ensure that
- the fields do not cross the boundary of 32 bits.
- the size of these structures is multiple of 32.
but in theory, the size and in-memory layout of structures is
implementation-dependent.
In the case of GCC, the layout is up to:
1. the word size of the target architecture
2. the largest member variable's size
3. if the member variable crosses the boundary of 32 bits
I checked GCC 4.3 on both amd64 and i386, and it seems we are safe as long
as user compiles sunpinyin with a decent GCC on these arch.
shall we add "__attribute__ ((packed))" at the end of persistent structures
with macro something like following?
#ifdef __GNUC__
#define PACKED __attribute__ ((packed))
#else
#define PACKED
#endif
Original issue reported on code.google.com by find...@gmail.com on 28 Feb 2010 at 4:22
Original issue reported on code.google.com by
find...@gmail.com
on 28 Feb 2010 at 4:22