Search code examples
c#pinvokestdcall

Pinvoke native method with pascal callingconvention


I have an old c++ librrary and all of methods exports with pascal calling convention, As i know c# marshaller does not support pascal calling convention, Can i use stdcall on c# side and pass parameters in reverse order?


Solution

  • pascal was a 16-bit calling convention, in 32-bit code it was replaced by __stdcall. The identifier was retained for source compatibility. CallingConvention.StdCall is the default for pinvoke so nothing special needed.

    You can find out more about DllImport.CallingConvention in this post, it mentions pascal.