Description
Description
While trying to run ImGui.NET on win-arm64 I ran into some sort of argument passing issue from managed to native code when calling https://github.com/cimgui/cimgui/blob/35a4e8f8932c6395156ffacee288b9c30e50cb63/cimgui.cpp#L207 via the managed wrapper https://github.com/ImGuiNET/ImGui.NET/blob/70a87022f775025b90dbe2194e44983c79de0911/src/ImGui.NET/Generated/ImGui.gen.cs#L21374
I managed to reproduce it with following stripped down version. Note that this code runs fine in win-x64
. It also runs fine in win-arm64
when removing the default constructor from the Vector2
struct. This makes me wonder whether it's even a dotnet issue, therefor feel free to point me to the appropriate channels if it isn't.
Reproduction Steps
C#
using System.Runtime.InteropServices;
var result = NativeMethods.MyFunction(default, default);
Console.WriteLine($"{nameof(NativeMethods.MyFunction)} returned {result}");
struct Vector2 { float x, y; }
static class NativeMethods
{
[DllImport("PInvoke.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int MyFunction(Vector2 vector, int value);
}
C++
struct Vector2
{
float x, y;
// Uncomment the following line and MyFunction returns the correct result
Vector2() : x(0.0f), y(0.0f) { }
};
extern "C" __declspec(dllexport) int MyFunction(Vector2 vector, int value)
{
return value;
}
Attached is a little VS solution containing the above code
PInvoke.zip
Expected behavior
MyFunction
should receive 0
as value
.
Actual behavior
MyFunction
receives some random number as value
.
Regression?
No response
Known Workarounds
No response
Configuration
.net8, Windows 11, ARM64
Other information
I've also tried building the project with clang but got the same result.
Metadata
Metadata
Assignees
Type
Projects
Status