在GCC中,stdcall是否有等效功能? [英] Is there any equivalent for stdcall in GCC?
问题描述
我正在使用GCC在我自己的内核上工作,并且当从asm代码调用C函数时,我必须自己做add esp,xx
.经过一番搜索,我发现stdcall
是Microsoft的发明,不能在GCC中使用它.有什么方便的方法可以完成这项工作吗?
I'm working on my own kernel using GCC, and when calling C functions from asm code, I have to do add esp,xx
myself. After some searching I found that stdcall
is a Microsoft invention and can't use it in GCC. Is there any handy way to do this work?
推荐答案
Linux中的stdcall是否等效?
Is there any equivalence of stdcall in linux?
我在Linux环境中的内核
my kernel in a linux environment
等等,这是您自己的内核还是Linux内核?因为如果它是您自己的内核,那么它将不再是Linux.
Wait, is this your own kernel, or the Linux kernel? Because if it's your own kernel, it's not Linux any more.
-
如果您使用的是Linux,则需要遵循常规的调用约定并编写要匹配的程序集.
If you're working on Linux, you'll want to stick with regular calling conventions and write your assembly to match.
如果您使用自己的内核,则可以做任何您想做的事情. GCC和Clang都支持ix86处理器上的stdcall
调用约定,例如
If you're working on your own kernel, you can do anything you want. GCC and Clang both support stdcall
calling conventions on ix86 processors, e.g.,
#define stdcall __attribute__((stdcall))
请参阅:函数属性(GCC手册)
这篇关于在GCC中,stdcall是否有等效功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!