gpt4 book ai didi

c# - C# 中非托管 DLL 的调用约定

转载 作者:行者123 更新时间:2023-11-28 02:21:10 26 4
gpt4 key购买 nike

我在 C++ 中创建了一个 DLL,并使用 [DllImport] 在 C# 中加载。

  1. 在不调用约定的情况下导出时,__cdecl 在 C++ 中是默认的吗?

  2. 可以将 CallingConvention.StdCall 或 CallingConvention.Winapi 与函数 __cdecl 一起使用吗? (它在我的测试中有效,而且我不使用“可变参数”)

最佳答案

Is __cdecl default in C++ when exporting without calling convention?

是的。

Is it okay to use CallingConvention.StdCall or CallingConvention.Winapi with the function __cdecl?

没有。使用 CallingConvention.Cdecl。使用错误的调用约定可能对某些函数有效,但这是错误的,并且在某些时候您会被抓到。

关于c# - C# 中非托管 DLL 的调用约定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32424091/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com