Hi Ray, thanks for this.
On 20 November 2013 10:21, Raymond Lu <songy...@hdfgroup.org> wrote: > On Linux, for "int" type, the value of COMP_ALIGN is 4. The C > keyword __alignof__ returns the alignment of the type in a structure, not > the alignment of the type in memory. Our library's algorithm of memory > alignment finds that the alignment for "int" is 1, meaning no alignment > restriction, on Linux. > I hope I am understanding the problem correctly. Reading http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/Alignment.html#Alignment it seems to me that __alignof__(type) returns the minimum required alignment for type as you need it. It's different if you do __alignof__(lvalue) because in that case the alignment of lvalue might be influenced in other ways. __alignof__(int) correctly returns 4 on my machine (x86_64). In general, I think it is a better approach to try to get all these information from the compiler. This can be done in many different ways, macro definitions, extension or even pattern matching based on compiler/platform. Best wishes, Andrea -- Andrea Bedini <andrea.bed...@gmail.com>
_______________________________________________ Hdf-forum is for HDF software users discussion. Hdf-forum@lists.hdfgroup.org http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org