Skip to content

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

Open
@OptimisticPeach

Description

@OptimisticPeach

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions