mirror of
https://github.com/hanzoai/yaegi.git
synced 2026-10-01 00:49:47 +00:00
Force recompute of bits.UintSize, make related tests portable. Fixes #1230.
27 lines
312 B
Go
27 lines
312 B
Go
package main
|
|
|
|
import (
|
|
"math/bits"
|
|
"unsafe"
|
|
)
|
|
|
|
const WSize = bits.UintSize / 8
|
|
|
|
type S struct {
|
|
X int
|
|
Y int
|
|
Z int
|
|
}
|
|
|
|
func main() {
|
|
x := S{}
|
|
size := unsafe.Sizeof(x) / WSize
|
|
align := unsafe.Alignof(x.Y) / WSize
|
|
offset := unsafe.Offsetof(x.Z) / WSize
|
|
|
|
println(size, align, offset)
|
|
}
|
|
|
|
// Output:
|
|
// 3 1 2
|