diff --git a/Directory.Packages.props b/Directory.Packages.props
index 926be196..6d314866 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -17,7 +17,7 @@
-
+
diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs
index dd9e744f..874c61d2 100644
--- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs
+++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs
@@ -191,10 +191,20 @@ private void VisitCallExpr(CallExpr callExpr)
{
case "memcpy":
{
+ var args = callExpr.Args;
+
if (Config.GenerateLatestCode)
{
outputBuilder.AddUsingDirective("System.Runtime.InteropServices");
outputBuilder.Write("NativeMemory.Copy");
+
+ if (args.Count == 3)
+ {
+ // Swap the operands around:
+ // * NativeMemory.Copy takes: source, dest, count
+ // * memcpy takes: dest, source, count
+ args = [args[1], args[0], args[2]];
+ }
}
else
{
@@ -202,7 +212,7 @@ private void VisitCallExpr(CallExpr callExpr)
outputBuilder.Write("Unsafe.CopyBlockUnaligned");
}
- VisitArgs(callExpr);
+ VisitArgs(callExpr, args);
break;
}