-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
cmd/cgo: treat Windows HANDLE as non-pointer type #42018
Comments
Gentle ping. Expanding use of Cgo in Gio on Windows is blocked by this issue that is subtle and has no workaround. |
Im curious: why not use the faster x/sys/windows syscall trampolines instead of cgo? |
We could. But Russ specifically says at #8921 (comment)
I read this as he does not want any exceptions in Cgo. Alex |
There's no support for window system functions.
His comment is from 2014, 3 years before adding special cases for CoreFoundation and Android JNI types. We don't even have to change the mapped type from unsafe.Pointer to uintptr anymore. |
I suspect it will be easy enough to add whatever functions you need. I would spend extra effort to avoid Cgo. I am even happy to try and implement them myself, if you want help. Just tell us which functions you need.
Yes. It has been long time. But still you have to take it up with Russ or Keith.
I am not familiar with compiler code. If you know what to change, just send CL to Russ or Keith or any compiler developer. Alex |
Thank you. I already have x/sys/windows wrappers for what I need for now. My primary motivation for pushing this issue is #38917. However, without a reliable HANDLE (and HWND) you can't make reliable Cgo Windows GUI programs.
I don't know what to change. My comment was to point out that while the older special cases (CoreFoundation, JNI) were breaking changing (Cgo generated type changed from unsafe.Pointer to uintptr), new special cases preserve the type but treat their values as non-pointers. |
OK.
Thanks for explaining.
I definitely cannot help you with that. Alex |
As far as I know the approach here would be to change cmd/cgo/gcc.go so that when it sees the type |
Change https://golang.org/cl/350070 mentions this issue: |
The Windows HANDLE type is translated to unsafe.Pointer by cgo. Unfortunately, HANDLE can contain valid non-pointer values, and should be treated accordingly. Incomplete pointer types such as the JNI types are covered by a rule so that they're not treated as pointers. However, that rule does not match HANDLE, which is typedef'ed to
void *
.From golang-dev:
Duplicate of #8921.
CC @randall77
The text was updated successfully, but these errors were encountered: