This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
vector of aligned elements
- From: "massimiliano cialdi" <cialdi at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 20 Jun 2008 09:13:12 +0200
- Subject: vector of aligned elements
is possoble to declare an array of element aligned?
for example is possible to declare an array of long aligned to 8 byte,
so as if &array[0] is x then &array[1] is x+MAX(8,sizeof(long))
I tried the following
#include <stdio.h>
typedef long aligned_long __attribute__ ((aligned (32)));
aligned_long a[4];
int main(void)
{
printf("test %d\n", sizeof(a));
return 0;
}
compiled with the following command line
gcc -Wall main.c -o main
(gcc 4.2.1)
I obtain this error
error: alignment of array elements is greater than element size
So is it impossible or is there another way?
this is not the real problem, I simply try to answer to the following question:
can I assume that (&array[1]-&array[0])==sizeof(array[0])?
thanks
--
Et nunc, auxilium solis, vincam!
Oppugnatio solaris!
VIS!
Massimiliano Cialdi
cialdi@gmail.com
massimiliano.cialdi@powersoft.it