gopherchina2018-cgo-talk
gopherchina2018-cgo-talk copied to clipboard
11.10节, uintptr 暂存到变量, golang文档不建议
Note that both conversions must appear in the same expression, with only the intervening arithmetic between them:
// INVALID: uintptr cannot be stored in variable // before conversion back to Pointer. u := uintptr(p) p = unsafe.Pointer(u + offset)
文档不建议是针对新手,这个报告的题目是深入cgo编程。 你需要理解为何不建议,哪些场景有风险。
unsafe包同样是不安全的,但是很多场景我们都喜欢这个不安全。