I created a DLL in C++ and loaded in C# with [DllImport].
Is __cdecl default in C++ when exporting without calling convention?
Is it okay to use CallingConvention.StdCall or CallingConvention.Winapi with the function __cdecl? (It worked in my test, and I don't use 'Variable Arguments')
Is
__cdecl
default in C++ when exporting without calling convention?
Yes.
Is it okay to use
CallingConvention.StdCall
orCallingConvention.Winapi
with the function__cdecl
?
No. Use CallingConvention.Cdecl
. Using the wrong calling convention might appear to work for some functions, but it is wrong, and at some point you will be caught out.