From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11029 invoked by alias); 20 Jun 2008 07:13:37 -0000 Received: (qmail 11015 invoked by uid 22791); 20 Jun 2008 07:13:36 -0000 X-Spam-Check-By: sourceware.org Received: from rv-out-0708.google.com (HELO rv-out-0708.google.com) (209.85.198.249) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 20 Jun 2008 07:13:14 +0000 Received: by rv-out-0708.google.com with SMTP id c5so6510421rvf.56 for ; Fri, 20 Jun 2008 00:13:12 -0700 (PDT) Received: by 10.141.4.3 with SMTP id g3mr7291995rvi.116.1213945992218; Fri, 20 Jun 2008 00:13:12 -0700 (PDT) Received: by 10.141.33.20 with HTTP; Fri, 20 Jun 2008 00:13:12 -0700 (PDT) Message-ID: <17201dc70806200013n47a283a7m8a74d462013db78d@mail.gmail.com> Date: Fri, 20 Jun 2008 07:13:00 -0000 From: "massimiliano cialdi" To: gcc-help@gcc.gnu.org Subject: vector of aligned elements MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-06/txt/msg00233.txt.bz2 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 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