[vsipl++] Matlab IO Patch

Mark Mitchell mark at codesourcery.com
Thu May 25 15:28:18 UTC 2006


Jules Bergmann wrote:
> 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?

No...  There's a GCC extension you can use (__attribute__((align))), but
that won't work on all compilers.  You could use:

  int32_t dim[2 * ((Dim + 1) / 2)];

which puts the padding into the array.

-- 
Mark Mitchell
CodeSourcery
mark at codesourcery.com
(650) 331-3385 x713



More information about the vsipl++ mailing list