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

后端 未结 2 793
深忆病人
深忆病人 2020-11-22 07:01

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++:



        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 07:50

    cdecl and stdcall are both valid and usable between C++ and .NET, but they should consistent between the two unmanaged and managed worlds. So your C# declaration for InvokedFunction is invalid. Should be stdcall. The MSDN sample just gives two different examples, one with stdcall (MessageBeep), and one with cdecl (printf). They are unrelated.

提交回复
热议问题