- eg 1:
1 package main 2 3 import ( 4 "fmt" 5 "unsafe" 6 ) 7 8 func main() { 9 fmt.Printf("%d\n", unsafe.Sizeof(struct { 10 a byte 11 i8 int 12 b byte 13 }{})) 14 }
结果:24
- eg 2:
1 package main 2 3 import ( 4 "fmt" 5 "unsafe" 6 ) 7 8 func main() { 9 fmt.Printf("%d\n", unsafe.Sizeof(struct { 10 i8 int 11 a byte 12 b byte 13 }{})) 14 }
-
结果:16
golang 内存对齐问题 记录
猜你喜欢
转载自www.cnblogs.com/ywdxz/p/11484040.html
今日推荐
周排行