linux编译 __stdcall,Linux下的stdcall 约定格式

在Windows中,函数调用约定有多种,如stdcall、cdecl和fastcall。然而,在Linux上,使用类似的语法会导致编译错误。Linux下,函数默认采用cdecl约定。若要指定stdcall约定,需使用`__attribute__((__stdcall__))`。示例代码展示了如何在Linux中定义和使用stdcall和cdecl约定的函数。
摘要由CSDN通过智能技术生成

Windows下的调用约定可以是stdcall/cdecl/fastcall,这些标识加在函数名前面,如:

int __stdcall funca()

但在Linux下,如按照上面写法后,编译程序将导致编译错误,Linux下正确的语法如下:

int __attribute__((__stdcall__)) funca()

int __attribute__((__cdecl__)) funca()

Linux下如果函数不指定调用约定,默认的情况应该是__attribute__((__cdecl__))

int __attribute__((__cdecl__)) myfunc(int i, int j, int k)

{

return i+j+k;

}

080483d0 :

80483d0:    55                       push   %ebp

80483d1:    89 e5                    mov    %esp,%ebp

80483d3:    8b 45 0c                 mov    0xc(%ebp),%eax

80483d6:    03 45 08                 add    0x8(%ebp),%eax

80483d9:    03 45 10                 add    0x10(%ebp),%eax

80483dc:    5d                       pop    %ebp

80483dd:    c3                       ret

80483de:    66 90 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值