rust-lang / rust-lang/rust-bindgen

Document somewhere that enums can be either c_int or c_uint

Open
#1,966 6 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted I-needs-docs
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Input C/C++ Header
enum TestEnum {
  FOO,
  BAR
};

Bindgen Invocation
$ bindgen input.h
Actual Results

On Windows:

/* automatically generated by rust-bindgen 0.56.0 */

pub const TestEnum_FOO: TestEnum = 0;
pub const TestEnum_BAR: TestEnum = 1;
pub type TestEnum = ::std::os::raw::c_int;

On Ubuntu:

/* automatically generated by rust-bindgen 0.56.0 */

pub const TestEnum_FOO: TestEnum = 0;
pub const TestEnum_BAR: TestEnum = 1;
pub type TestEnum = ::std::os::raw::c_uint;
Expected Results

This should be documented somewhere. All I found is this comment: https://github.com/rust-lang/rust-bindgen/issues/1096#issuecomment-365797349

Bindgen uses whatever enum type comes from clang, so if it's a u32, clang is picking a u32 type for it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report uses input.h and the bindgen input.h entry point, with generated Rust output differing between Windows and Ubuntu. Start by locating the project’s enum or code-generation documentation; document that bindgen follows Clang’s platform-selected enum type, including c_int versus c_uint, and verify the example’s behavior on both platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp, rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.