From: Matt Corallo Date: Fri, 7 Jun 2024 01:26:57 +0000 (+0000) Subject: [C#] Fix bool passing X-Git-Tag: v0.0.123.1^2~8 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=621144a2e43bc92cf44b7ac4bd5a141e22f384f6;p=ldk-java [C#] Fix bool passing It turns out that C# always expects bools to be passed as 4-byte ints, which matches the classic C definition (which was usually typedef'd to int) but is platform-dependent. On some platforms we were building with 1-byte ints which led to bools getting mangled when passing them to C#. Luckily we already have bools passed to C# separated from bools passed to Rust, so we can simply redefine `jboolean` to `int32_t`. --- diff --git a/csharp_strings.py b/csharp_strings.py index 3e5e247d..3b0f9f1a 100644 --- a/csharp_strings.py +++ b/csharp_strings.py @@ -442,7 +442,8 @@ static inline LDKStr str_ref_to_owned_c(const jstring str) { return res; } -typedef bool jboolean; +// The C# Bool marshalling is defined as 4 bytes, but the size of bool is platform-dependent +typedef int32_t jboolean; int64_t CS_LDK_allocate_buffer(int64_t len) { return (int64_t)MALLOC(len, "C#-requested buffer");