Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This update elevates
BOOL
to a "core type" in thewindows-bindgen
crate. Consider the following simple example generating bindings for theEnableMouseInPointer
function from a build script.That's pretty simple. The
windows-targets
crate provides linker support but otherwise these bindings are dependency-free. But what if I remove the--sys
option?"--in default --out src/bindings.rs --flat --filter EnableMouseInPointer"
This looks mostly right. The richer bindings take care of a bit of type conversion and error handling. The trouble is that the wrapper function expects the
BOOL
type to provide anok
method for retrieving the Win32 error code and converting it to aResult
value. The parameter also expects anInto
implementation to convert frombool
toBOOL
.One option is to use the new
--reference
option to explicitly tellwindows-bindgen
where to find theBOOL
implementation rather than simply generating it as a simple struct."--in default --out src/bindings.rs --flat --filter EnableMouseInPointer --reference windows,skip-root,Windows"
This works, but does require that you add a dependency on the
windows
crate with the "Win32_Foundation" feature enabled. The main drawback here is the sheer size of thewindows
crate. Its great for apps but doesn't work well as a dependency of a library crate that isn't entirely focused on Windows development.Well by elevating
BOOL
to a core type, the following produce bindings that only depend on the tinywindows-core
crate and avoids thewindows
crate entirely."--in default --out src/bindings.rs --flat --filter EnableMouseInPointer"
I considered a few other approaches but ultimately
BOOL
is just too foundational and important of a Windows type and this "just works" for the most common scenarios.Fixes: #3439