From b3ae554bd96d2397cdfadcedffc1743268415212 Mon Sep 17 00:00:00 2001 From: vasilito Date: Tue, 28 Jul 2026 15:46:41 +0900 Subject: [PATCH] relibc: fix netinet/ip.h cbindgen double-struct (struct struct ip) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit netinet_ip/cbindgen.toml both exports (defines) struct ip/iphdr AND had [export.rename] mapping them to 'struct ip'/'struct iphdr'. With style=Tag, cbindgen already prefixes a struct declaration with 'struct', so the rename produced 'struct struct ip { ... }' — a C syntax error (expected '{' before 'struct') that broke every C consumer of (e.g. dbus's dbus-print-message.c). The 'X' -> 'struct X' rename is only correct for types REFERENCED from another header (tag-style forward ref, e.g. arpa_inet's in_addr); it must NOT be used for a type defined+exported in the same header. Removed the rename; both structs are native Rust defs so cbindgen emits 'struct ip'/'struct iphdr' correctly. Regenerated header verified (0 double-struct, diff = only the two struct-name lines). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/header/netinet_ip/cbindgen.toml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/header/netinet_ip/cbindgen.toml b/src/header/netinet_ip/cbindgen.toml index fcb3293718..5a07252db7 100644 --- a/src/header/netinet_ip/cbindgen.toml +++ b/src/header/netinet_ip/cbindgen.toml @@ -11,10 +11,11 @@ cpp_compat = true [export] include = ["ip", "iphdr"] - -[export.rename] -"ip" = "struct ip" -"iphdr" = "struct iphdr" +# NB: do NOT add [export.rename] mapping "ip" -> "struct ip". With style = "Tag" +# cbindgen already emits `struct ip { ... }` for a struct named `ip`; renaming +# the type to "struct ip" makes it emit `struct struct ip { ... }`, which is a +# C syntax error ("expected '{' before 'struct'"). Both `ip` and `iphdr` are +# defined as native Rust structs, so no rename is needed for either name. [enum] prefix_with_name = true \ No newline at end of file