From 220ea061ae58f4a948bdcb3823368f0deeb3d2b5 Mon Sep 17 00:00:00 2001 From: kaju Date: Wed, 4 Mar 2026 09:25:02 +0000 Subject: [PATCH] fix: use consistent u32 type for enum constants on Windows bindgen generates C enum constants as i32 on Windows MSVC (C enums are always 'int') but u32 on Linux/macOS. This causes type mismatches when consumers assign these constants to u32 fields. Add .default_enum_style(bindgen::EnumVariation::Consts) and .translate_enum_integer_types(true) to generate consistent u32 types across all platforms. --- build.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.rs b/build.rs index 2dcfe45..8810dd5 100644 --- a/build.rs +++ b/build.rs @@ -266,6 +266,11 @@ fn generate_bindings(out_dir: &Path, include_dir: &Path) { .allowlist_function("nghttp2_.*") .allowlist_type("nghttp2_.*") .allowlist_var("NGHTTP2_.*") + // Generate enum constants with consistent types across platforms. + // Without this, C enums become i32 on MSVC (C standard: enum is int) + // but u32 on GCC/Clang (where the underlying type matches the values). + .default_enum_style(bindgen::EnumVariation::Consts) + .translate_enum_integer_types(true) // Opaque types that should not derive Copy .opaque_type("nghttp2_session") .opaque_type("nghttp2_rcbuf")