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

Feature request: windows_bindgen::standalone should allow specifying specific enum constants #2409

Closed
Jake-Shadle opened this issue Mar 30, 2023 · 2 comments · Fixed by #2430
Labels
enhancement New feature or request

Comments

@Jake-Shadle
Copy link
Contributor

Motivation

Currently, windows_bindgen::standalone will emit every constant in an enum with no way to filter to only the ones that are needed by the crate using the bindings. As a consequence #![allow(dead_code)] is always emitted in the generated bindings so the user doesn't get warnings for the unused constants.

Drawbacks

In a vast majority of use cases, only a small fraction of enum values are used from any particular enum, from the relatively tame PAGE_ flags enum to the frankly insane (at the time of this writing) 3240 item WIN32_ERROR. While it's not the end of the world, refining the emitted items to only the ones requested by the user means less generated code and thus less code to compile.

Rationale and alternatives

The impact of not doing this is that crates which generate enum bindings with windows_bindgen::standalone will almost always be compiling code they don't use. This cost will be negligible in the grand scheme of things, but there's also no reason to give the compiler more work to do if it can be avoided. It also means that if the user manually removes the items they don't use, regenerating the bindings will need manual cleanup every time rather than just having a feature to always emit bindings without a need for manual fixup.

Additional context

No response

@Jake-Shadle Jake-Shadle added the enhancement New feature or request label Mar 30, 2023
@kennykerr
Copy link
Collaborator

This one's a little trickier but agreed it would be nice if this were possible.

@kennykerr
Copy link
Collaborator

And here's the fix for this issue: #2430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants