C在GCC中的功能对齐 [英] C Function alignment in GCC
问题描述
我正在尝试使用'aligned(16)'属性将函数按字节对齐到16个字节的边界.我做了以下工作:void __attribute__((aligned(16))) function() { }
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() { }
(来源: http://gcc.gnu.org/onlinedocs/gcc /Function-Attributes.html )
但是当我编译(gcc foo.c;不使用任何makefile文件或链接程序脚本)时,出现以下错误:
But when I compile (gcc foo.c ; no makefiles or linker scripts used), I get the following error:
FOO.c:99:错误:可能未为功能"指定对齐方式
FOO.c:99: error: alignment may not be specified for 'function'
我也尝试对齐到4,8,32等,但是错误仍然相同. 我需要它来为基于Powerpc的处理器调整中断服务例程.正确的方法是什么?
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 ?
推荐答案
为什么在编译时不只是将 -falign-functions = 16 传递给gcc?
Why don't you just pass the -falign-functions=16 to gcc when compiling?
这篇关于C在GCC中的功能对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!