* xjdrew <xj.d...@gmail.com> [170522 02:06]: > How can i use this kind of Go in windows? my machine is 64bit also. If I > download the amd64 Go, the pointer size will be 8 bytes. > > My real issue is , when I call win32 api, uint64 type in the struct of > win32 is aligned to 8 bytes. > I have to pad the go struct by manual to make it work with win32 api. > > > On Friday, May 19, 2017 at 7:28:54 AM UTC-4, xjdrew wrote: > >> Code as below, playground url(https://play.golang.org/p/XSx--6uF0E): > >> > >> package main > >> > >> import "fmt" > >> import "unsafe" > >> > >> type A struct { > >> a uint8 > >> b uint64 > >> } > >> func main() { > >> a := &A{} > >> fmt.Println(unsafe.Sizeof(a)) > >> fmt.Println(unsafe.Sizeof(*a)) > >> }
As Dan said, you have not given us enough information to provide you with useful help (at least not without a lot of good guessing on our part as to what you are really trying to do). I am guessing that you are importing "golang.org/x/sys/windows" and using syscall to call functions in DLLs. If so, what DLL and what entry? What is the C structure you are trying to pass to that entry? Must it work in both win32 and win64? When you are mixing Go and C ABIs, there is likely to be some manual alignment, especially if you are trying to do this on multiple OS/architecture combinations (e.g. win32 and win64). I believe (but am not 100% positive) that on all platforms supported by Go, the following will produce the same alignment: type A struct { a uint8 _ uint32 b uint64 } ...Marvin -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.