Align attribute on struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am trying to ask gcc to align a struct but it is not working. Here's a
program I wrote to show what I am trying to do:

#include <stdio.h>

typedef struct {
    int a, b, c;
} s __attribute__ ((aligned (16)));

int data[] = {1, 2, 3, 4, 5, 6, 7, 8};

int main(void)
{
    printf("%d\n", ((s *)data)[0].a);
    printf("%d\n", ((s *)data)[1].a);

    return 0;
}

Compiling with gcc 4.4.1:

$ gcc test.c
$ ./a.out
1
4

I would expect the output to be 1 and 5. Am I missing something?

Thank you,

Rodrigo



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux