Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to try to fit macro constants into smaller integer types #1945

Closed
wants to merge 3 commits into from

Conversation

Skelebot
Copy link
Contributor

Add a --fit-macro-constant-types option to make bindgen try to fit
macro integer constants into rust integer types smaller than u32/i32.
Especially useful when dealing with 8/16-bit architectures.

Add a `--fit-macro-constant-types` option to make bindgen try to fit
macro integer constants into types smaller than u32/i32.
Useful especially when dealing with 8/16-bit architectures.
@emilio
Copy link
Contributor

emilio commented Dec 18, 2020

This looks ok, but needs a test and rustfmt is failing. Thanks!

@Skelebot
Copy link
Contributor Author

As you can see, I re-used the test header for default-macro-constant-type to also include u8/i8 and u16/i16 values so that it can also be used to test fit-macro-constant-types. My question is - would it be useful to create separate tests for default-macro-constant-type=signed/unsigned with fit-macro-constant-types or testing them separately is sufficient?

@emilio emilio closed this in ea4164c Dec 19, 2020
Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm on vacation now so I have a bit more time than usual, so I squashed the commits, cleaned up a bit to avoid duplication in 5c82186, and added the extra test in 4ce4b93 since I think it's worth having both code-paths covered.

Thank you!

LoganBarnett pushed a commit to LoganBarnett/rust-bindgen that referenced this pull request Dec 2, 2023
Add a `--fit-macro-constant-types` option to make bindgen try to fit
macro integer constants into types smaller than u32/i32.
Useful especially when dealing with 8/16-bit architectures.

Closes rust-lang#1945
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants