相当于 gcc/g++ 中的 __declspec( bare )
gcc/g++ 中的 __declspec(naked)
等价于什么? __declspec( bare )
实际上是用来声明一个没有尾声和序言的函数。
What is the equivalent of __declspec( naked )
in gcc/g++? __declspec( naked )
is actually used to declare a function without any epilogue and prologue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在某些体系结构上,gcc 支持称为“naked”的属性;最新的 gcc 文档 我给出了以下架构列表:ARM、 AVR、MCORE、RX 和 SPU。
如果您正在使用其中一种架构(如果您尝试使用它并且它不受支持,gcc 会向您发出警告),则可以像这样使用该属性:
[There's was a bit of最近在 gcc 开发人员列表上讨论了如何将“naked”属性添加为更通用的功能,并尝试在更多架构上支持它,但显然这对您没有帮助:)。]
On some architectures, gcc supports an attribute called "naked"; the most recent gcc docs I have give this list of architectures: ARM, AVR, MCORE, RX and SPU.
If you are using one of those architectures (gcc will give you a warning if you try to use it and it isn't supported), the attribute can be used like this:
[There's been a bit of discussion recently on the gcc developer list about adding the "naked" attribute as a more general feature, and trying to support it on more architectures, but obviously that doesn't help you :).]
我相信 Linux 下最近的 GCC 没有这样的等价物。编译器在适当的时候发出序言和尾声,您应该将这个决定留给它。它可能非常擅长使序言或尾声变得非常小,甚至有时甚至不存在。
您可以用汇编语言编写您的函数。或者您可以将 asm 语句放入您的函数中。
而且你没有说出为什么要这样做。您的目标是什么?您为什么要问?
I believe there is no such equivalent with a recent GCC under Linux. The compiler emit prologues and epilogues when appropriate, and you should leave that decision to it. It may be quite good at making prologues or epilogues quite small, or even sometimes non-existent.
You could code your function in assembly. Or you can put asm statements inside your function.
And you did not tell why you want to do that. What is your goal, and why precisely are you asking?