Forum Discussion
Altera_Forum
Honored Contributor
15 years agoPointer help - alignment issue
I need to use a pointer to a long that is not word aligned (I think). Here is sample code void func(void) { char Test[12] = { 1, 2, 3,4 ,5 ,6, 7, 8, 9, 10, 11, 12}; long * temp; ...
Altera_Forum
Honored Contributor
15 years agoActually that one tries to apply the attribute to pvar, not *pvar.
Define a type that has the attribute attached, otherwise it is difficult to get it applied to the right place (even when it does work). A structure containing a single alignment-contrained integer does work. So maybe you need: typedef struct { int v __attribute__((aligned(2))); } int_aligned_16_t; and use that inside the other structures - so you only look at the 'v' member when you want the value itself.