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

windows-sys doesn't distinguish between LPCWSTR and LPWSTR #1504

Closed
maroider opened this issue Feb 5, 2022 · 3 comments · Fixed by #1550
Closed

windows-sys doesn't distinguish between LPCWSTR and LPWSTR #1504

maroider opened this issue Feb 5, 2022 · 3 comments · Fixed by #1550
Labels
enhancement New feature or request

Comments

@maroider
Copy link

maroider commented Feb 5, 2022

Crate version: 0.32.0

This is similar to #1490, but perhaps a bit more specific.

windows-sys doesn't distinguish between mutable and immutable string pointers, so all functions get whatever LPWSTR is aliased to (used to be *mut u16, now it's *const u16). With type LPWSTR = *const u16, APIs like GetWindowTextW now take a *const u16 where they should take a *mut u16, which is a problem.

There's a similar issue with ImmSetCompositionWindow, where the function is documented on MSDN as taking an LPCOMPOSITIONFORM (*mut COMPOSITIONFORM), but windows-sys says it takes a *const COMPOSITIONFORM.

@kennykerr
Copy link
Collaborator

This is the same signature issue as #1496.

@kennykerr
Copy link
Collaborator

Note that this applies to GetWindowTextW (same as #1496). It's less clear to me that there's anything wrong with the way ImmSetCompositionWindow is defined. The docs and metadata say that it has input parameters and I don't see anything that could be used to infer that it needs to be mutable.

@kennykerr
Copy link
Collaborator

#1550 adds first-class types for PCSTR and PCWSTR.

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