From: Matt Corallo Date: Sat, 3 Jul 2021 01:28:25 +0000 (+0000) Subject: Skip trait typedef in extra header as its unnecessary X-Git-Tag: v0.0.99.0^2~6 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=74665e3b6e24cb9dc4d9c6cd68db2a9ba02d72ad;p=ldk-c-bindings Skip trait typedef in extra header as its unnecessary ... and OSX complains that "redefinition of typedef...is a C11 feature" --- diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index 8bbbdf0..9693e3d 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -280,10 +280,9 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty writeln!(w, "\tpub set_{}: Option,", m.sig.ident, trait_name).unwrap(); generated_fields.push((format!("set_{}", m.sig.ident), true)); // Note that cbindgen will now generate - // typedef struct Thing {..., set_thing: (const Thing*), ...} Thing; + // typedef struct Thing {..., set_thing: (const struct Thing*), ...} Thing; // which does not compile since Thing is not defined before it is used. writeln!(extra_headers, "struct LDK{};", trait_name).unwrap(); - writeln!(extra_headers, "typedef struct LDK{} LDK{};", trait_name, trait_name).unwrap(); continue; } // Sadly, this currently doesn't do what we want, but it should be easy to get @@ -317,7 +316,6 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty ("std::cmp::Eq", _)|("core::cmp::Eq", _) => { writeln!(w, "\t/// Checks if two objects are equal given this object's this_arg pointer and another object.").unwrap(); writeln!(w, "\tpub eq: extern \"C\" fn (this_arg: *const c_void, other_arg: &{}) -> bool,", trait_name).unwrap(); - writeln!(extra_headers, "typedef struct LDK{} LDK{};", trait_name, trait_name).unwrap(); generated_fields.push(("eq".to_owned(), true)); }, ("std::hash::Hash", _)|("core::hash::Hash", _) => {