[vsipl++] Matlab IO Patch
Jules Bergmann
jules at codesourcery.com
Thu May 25 15:03:14 UTC 2006
Mark Mitchell wrote:
> Jules Bergmann wrote:
>
>> int32_t pad[Dim%2];
>> data_element array_name_header;
>
> Zero-element arrays are not valid ISO C++. However, if data_element is
> a 64-bit type, then it will be aligned to an 8-byte boundary on most
> systems.
Thanks Mark for pointing that out, I was worried that zero-element
arrays might not work :(
data_element is a struct containing two 32-bit types, will that be
aligned to 64-bits?
If we rely on compiler to do the padding for us, we definitely should
capture this with an assertion so that we know if it ever breaks.
Alternatively, we could use a union to do the padding, something like:
union
{
int32_t dim[Dim];
int32_t pad[Dim + Dim%2];
}
>
>> For int, we need some support from configure.ac to determine whether int is 32 bits (miINT32) or 64 bits (miINT64).
>
> Why not just:
>
> template <>
> struct Matlab_type_traits<int>
> {
> static int const data_type = sizeof (int) == 4) ? miINT32 : miINT64;
> }
Good suggestion, thanks!
-- Jules
--
Jules Bergmann
CodeSourcery
jules at codesourcery.com
(650) 331-3385 x705
More information about the vsipl++
mailing list