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
We need a way to distinguish handles from pointers from pointer-sized integers #21
Comments
I hadn't heard of Also, after doing a little more reading, I learned that my hunch is probably still correct. Despite their names |
Yes, |
This should be fixed with the work done for NativeTypedef structs. Let me know if there is still more here that doesn't look right. |
Here's one issue I see with making handle types the integral type |
I think it's really up to the language projection authors and what they think works best for their languages. Notice what @AArnott (the author of CsWin32) said at the top:
It's easy for me to change handles from IntPtr to void* if it makes their projections better, but so far I haven't heard that from the projection authors. |
The problem here is that we've established that Note that this discrepancy is easy to workaround by simply replacing all As the author of the Zig projection I can attest that I'd prefer to use |
I think it would be worse to advertise "this opaque handle value is a pointer to something" than to be forced to use the syntax IntPtr.Zero instead of NULL. |
Regardless of what people want to say about
"Opaque handles" in Windows frequently behave as truly opaque values, but they equally have cases where values in the range For opaque handles, I see three options for the raw signatures:
The typical convention in .NET has been to define this as I think that using |
If that's true, it only applies where these types appear outside of a typedef. The typedef structs are (mostly) strongly-typed wrappers for handles. |
Is this the currently accepted behavior? If so, does that mean that GetWindowLongPtr and SetWindowLongPtr should be using |
Yes, I believe that is the behavior we're shooting for.
I'm not sure which type you're referring to, as 3 types exist on those method signatures.
But keep in mind that there is no such thing as |
Ryan said:
I agree. We need to distinguish handles/pointers from pointer-sized integers for the best language experience.
In .NET, we want to use
IntPtr
for handles,void*
for pointers, andnint
for integers that the user may actually care to read/write.The text was updated successfully, but these errors were encountered: