AllenDang / w32

A wrapper of windows apis for the Go Programming Language.
Other
761 stars 245 forks source link

failed install on Windows 10 Home 64 bit #80

Open pengo1998 opened 6 years ago

pengo1998 commented 6 years ago

when running go install it returns with

.\user32.go:1039:10: cannot use flag (type uint32) as type uintptr in argument to procRedrawWindow.Call

jessehager commented 6 years ago

I have the same problem on go version go1.10.2 windows/amd64. Build is broken.

To be compatible with 64-bit go, line 1040 of user32.go probably needs to be changed from

flag,

to

uintptr(flag),

I changed it in my local copy and the compile error went away and the package built without any problems. I don't use RedrawWindow though so I don't know if the function breaks. And my knowledge of the syscall package is pretty much nonexistent so I can't be 100% sure this change is correct.

TheTitanrain commented 6 years ago

Working version (https://github.com/jessehager correction): go get github.com/TheTitanrain/w32

Aareon commented 5 years ago

Does the unintptr(flag) fix also work for 32-bit systems, as well as non-Home editions of Windows?

jessehager commented 5 years ago

Yes, uintptr is an integer type of the same size as whatever the underlying pointer size is. On 64-bit systems it is 64 bits. On 32-bit systems it is 32 bits. For the windows api C/C++ compilers perform integer to uintptr_t conversions automatically. In the api wrapper uintptr is not mapped to one of Go's underlying integer types, but treated as an opaque type. So Go's type system requires an explicit conversion in this case.

gonutz commented 4 years ago

I have an actively maintained fork which I use to create both 32 and 64 bit applications, both for work and for private projects. It has diverged quite a bit from this original fork. You could give it a try instead:

https://github.com/gonutz/w32