Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C Function alignment in GCC

I am trying to byte-align a function to 16-byte boundary using the 'aligned(16)' attribute. I did the following: void __attribute__((aligned(16))) function() { }

(Source: http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html)

But when I compile (gcc foo.c ; no makefiles or linker scripts used), I get the following error:

FOO.c:99: error: alignment may not be specified for 'function'

I tried aligning to 4,8,32, etc as well but the error remains the same. I need this to align an Interrupt Service Routine for a powerpc-based processor. What is the correct way of doing so ?

like image 817
Sukanto Avatar asked Dec 16 '09 07:12

Sukanto


1 Answers

Why don't you just pass the -falign-functions=16 to gcc when compiling?

like image 79
Gonzalo Avatar answered Oct 24 '22 11:10

Gonzalo