Skip to content

Commit b5dfafb

Browse files
committed
fix marshalling for bool ret
1 parent 522efcb commit b5dfafb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

managed/IronCompress/Iron.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ public static bool SupportsNative(Codec c) {
4848
}
4949

5050
public static string GetNativeVersion() {
51-
return Native.iron_version();
51+
IntPtr ptr = Native.iron_version();
52+
string version = Marshal.PtrToStringAnsi(ptr);
53+
return version;
5254
}
5355

5456
/// <summary>

managed/IronCompress/Native.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ internal static extern unsafe bool iron_compress(bool compress,
4747
int compressionLevel);
4848

4949
[DllImport(LibName)]
50+
[return: MarshalAs(UnmanagedType.I1)]
5051
internal static extern bool iron_ping();
5152

5253
[DllImport(LibName)]
54+
[return: MarshalAs(UnmanagedType.I1)]
5355
internal static extern bool iron_is_supported(int codec);
5456

5557
[DllImport(LibName)]
56-
internal static extern string iron_version();
58+
internal static extern IntPtr iron_version();
5759
}
5860
}

0 commit comments

Comments
 (0)