stdcall

stdcall and cdecl

女生的网名这么多〃 提交于 2019-11-26 06:55:46
问题 There are (among others) two types of calling conventions - stdcall and cdecl . I have few questions on them: When a cdecl function is called, how does a caller know if it should free up the stack ? At the call site, does the caller know if the function being called is a cdecl or a stdcall function ? How does it work ? How does the caller know if it should free up the stack or not ? Or is it the linkers responsibility ? If a function which is declared as stdcall calls a function(which has a

Why are Cdecl calls often mismatched in the “standard” P/Invoke Convention?

时光总嘲笑我的痴心妄想 提交于 2019-11-25 22:49:41
问题 I am working on a rather large codebase in which C++ functionality is P/Invoked from C#. There are many calls in our codebase such as... C++: extern \"C\" int __stdcall InvokedFunction(int); With a corresponding C#: [DllImport(\"CPlusPlus.dll\", ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.Cdecl)] private static extern int InvokedFunction(IntPtr intArg); I have scoured the net (insofar as I am capable) for the reasoning as to why this apparent mismatch