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
Unnecessary *mut constraint in LPCTSTR #549
Comments
Yes, this is something we can improve. The struct field in this case includes a "const" attribute in metadata so we just need to ensure that this translates into a |
This is now a little better thanks to the introduction of the PWSTR and PSTR types. Here's an example: https://github.com/microsoft/windows-rs/blob/master/examples/create_window/src/main.rs Beyond that, I'd like to introduce const functions or macros that can produce a PWSTR/PSTR from a literal. That's tracked by #581. |
|
Agreed its not yet ideal or safe, but why is it UB? The memory is not actually modified. |
I was mistaken, it's not directly UB, I believe I was thinking of
If they're considered to be |
These are now |
MSDN documentation of WNDCLASSEXW,
states the field
lpszClassName
has typeLPCTSTR
which is a pointer to constant string.However, the generated bindings on WNDCLASSEXW defines the field as
*mut 16
, which seems overly constrained for constant (t-)strings.Current workaround is just casting *const pointers into *mut, but it could be more simple to define them as *const pointers.
The text was updated successfully, but these errors were encountered: