Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# examples use default calling convention while rust is different #86

Open
OptimisticPeach opened this issue Jul 24, 2019 · 0 comments

Comments

@OptimisticPeach
Copy link

OptimisticPeach commented Jul 24, 2019

The extern functions declared here are all marked as the following: (In C#)

[DllImport("dll_name")]
private static extern ret name(params object parameters);

Which is incorrect with respect to the calling convention.

The default ABI for rust extern functions is defined as follows:

By default external blocks assume that the library they are calling uses the standard C ABI on the specific platform.

And as defined here:

// Declares an extern fn, the ABI defaults to "C"
extern fn new_i32() -> i32 { 0 }

And in the MS docs pages:

The default value for the CallingConvention field is Winapi, which in turn defaults to StdCall convention.

Therefore the C# code should change to the following:

[DllImport("dll_name", CallingConvention = CallingConvention.Cdecl)]
private static extern ret name(params object parameters);

Thank you for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant