c++ - 为什么 gcc 不支持裸函数?

标签 c++ linux gcc g++

我使用裸函数在程序运行时修补部分程序。我可以在 Windows 的 VC++ 中轻松地做到这一点。我正在尝试在 Linux 中执行此操作,但 gcc 似乎不支持裸函数。用裸函数编译代码给我这个:警告:‘naked’属性指令被忽略。在 CentOS 5.5 i386 下编译。

最佳答案

根据 docs,裸属性仅在某些平台(ARM、AVR、MCORE、RX 和 SPU)上受 GCC 支持。 :

naked: Use this attribute on the ARM, AVR, MCORE, RX and SPU ports to indicate that the specified function does not need prologue/epilogue sequences generated by the compiler. It is up to the programmer to provide these sequences. The only statements that can be safely included in naked functions are asm statements that do not have operands. All other statements, including declarations of local variables, if statements, and so forth, should be avoided. Naked functions should be used to implement the body of an assembly function, while allowing the compiler to construct the requisite function declaration for the assembler.

我不知道为什么。

关于c++ - 为什么 gcc 不支持裸函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7278234/

相关文章:

c++ - 哪个运营商删除?

linux - 如何在Openwrt中降级内核版本?

linux - EC2 上没有 C 编译器?

c - c/c++ 中的 gcc 编译器是否保证将指向 const 数据的全局 const 指针放置在单独的只读部分中?

c++ - 被通告扼杀的 friend 功能包括

c++ - 是否可以从图像计算速度?

c++ - 使用 typedef、多维数组和指针时出现编译器错误

linux - 查找,grep gzipped 文件

c - Linux Makefile.am 错误 "undefined reference to"

c++ - 为什么 g++ 将计算拉入热循环?