August 13th, 2003, 11:29 PM
[gcc] attribute aligned
I am a beginner in C, et i have some problem understanding the aligned attribute of gcc.
ex <type> x __attribute__((aligned(nb_bytes))));
(x is the name of the variable, type is its type, and nb_bytes the number of byte to align ).
I test on a solaris machine,
and for example.
i do :
char x __attribute__((aligned(4)));
but the adress of x (&x), is never like &x % 4 == 0
and what can be the maximun size of aligned (is it the max size of memory that the proc can take in 1 clock ?? )
thanks for your help
August 15th, 2003, 07:04 PM
August 15th, 2003, 09:02 PM
i have done :
=> &x == effff14a
if i put aligned (4), i have the same address !!
August 15th, 2003, 09:12 PM
in fact, i precise that I compile in solaris/sun station.
which is big endian, so :
int x is 4 bytes long.
&x is the adress of the MSB.
the adress of the LSB is greater than the adresse of the MSB.