Skip to content

fix: use consistent u32 type for enum constants on Windows#4

Merged
littledivy merged 1 commit intodenoland:mainfrom
kajukitli:fix/windows-enum-types
Mar 4, 2026
Merged

fix: use consistent u32 type for enum constants on Windows#4
littledivy merged 1 commit intodenoland:mainfrom
kajukitli:fix/windows-enum-types

Conversation

@kajukitli
Copy link
Copy Markdown
Contributor

bindgen generates enum constants as i32 on Windows MSVC (C standard: enum underlying type is int) but u32 on GCC/Clang when all values are non-negative. This causes type mismatch errors when using the constants.

Add .default_enum_style(bindgen::EnumVariation::Consts) combined with .translate_enum_integer_types(true) to force consistent unsigned types across all platforms.

Fixes errors like:

error[E0308]: mismatched types
   --> ext\node\ops\http2\session.rs:515:33
    |
515 |     if frame.hd.type_ as u32 == ffi::NGHTTP2_PUSH_PROMISE {
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32`

bindgen generates enum constants as i32 on Windows MSVC (C standard:
enum underlying type is int) but u32 on GCC/Clang when all values are
non-negative. This causes type mismatch errors when using the constants.

Add .default_enum_style(bindgen::EnumVariation::Consts) combined with
.translate_enum_integer_types(true) to force consistent unsigned types
across all platforms.
@littledivy littledivy merged commit 66a01c8 into denoland:main Mar 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants