Unsafe的使用

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_21576535/article/details/81114331
//var i uint16 = 0xFFFE
//bs := (*[int(unsafe.Sizeof(i))]byte)(unsafe.Pointer(&i))
//fmt.Println(*bs)
//ii:=(*uint16)(unsafe.Pointer(&*bs))//指针强转
//fmt.Println(*ii)
/**结构体转BTYE 与BYTE与结构体直接的互转***/
//var strc = A{}
//strc.B = 100
//strc.C =200
//data := *(*[unsafe.Sizeof(strc)]byte)(unsafe.Pointer(&strc))
//fmt.Println(data)
//strc1:= *(*A)(unsafe.Pointer(&data))
//fmt.Println(strc1)
展开阅读全文

没有更多推荐了,返回首页