Skip to content

Commit 1692f44

Browse files
committed
fix: use consistent u32 type for enum constants on Windows
bindgen generates C enums as i32 by default, but on Windows MSVC this can cause type mismatches when consuming code expects u32 constants. Use EnumVariation::Consts to generate all enum constants as u32 for cross-platform consistency.
1 parent 72ea8e6 commit 1692f44

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ fn generate_bindings(out_dir: &Path, include_dir: &Path) {
266266
.allowlist_function("nghttp2_.*")
267267
.allowlist_type("nghttp2_.*")
268268
.allowlist_var("NGHTTP2_.*")
269+
// Generate enum constants as u32 for cross-platform consistency
270+
// (C enums are `int` on MSVC → i32, but unsigned on GCC/Clang → u32)
271+
.default_enum_style(bindgen::EnumVariation::Consts)
272+
.translate_enum_integer_types(true)
269273
// Opaque types that should not derive Copy
270274
.opaque_type("nghttp2_session")
271275
.opaque_type("nghttp2_rcbuf")

0 commit comments

Comments
 (0)