开发者

Attempting COM, Does C# use stdcall by default, or do you have to specify

开发者 https://www.devze.com 2023-02-20 15:59 出处:网络
The book I\'m using describes C++ 开发者_StackOverflowusage of COM and recommends __stdcall as a specifier, arguing that more languages use this method of stack cleanup.

The book I'm using describes C++ 开发者_StackOverflowusage of COM and recommends __stdcall as a specifier, arguing that more languages use this method of stack cleanup.

However, I'm considering future interoperability with C#. Does C# use stdcall by default, or does it have to be specified?


With COM interop, it doesn't matter as much.

If you're using Platform Invocation Services (P/Invoke), with C#, then stdcall is the default. (Technically, it's Winapi, which defaults to Stdcall on the desktop), but it can be overriden in a DllImport specification.


I would recommend using stdcall as the default specifier as it's the default used by C#. However, it's trivial to change the calling convention via "CallingConvention" attribute.

http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.callingconvention.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消