gopherchina2018-cgo-talk icon indicating copy to clipboard operation
gopherchina2018-cgo-talk copied to clipboard

11.10节, uintptr 暂存到变量, golang文档不建议

Open memetea opened this issue 6 years ago • 1 comments

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)

memetea avatar Mar 27 '18 06:03 memetea

文档不建议是针对新手,这个报告的题目是深入cgo编程。 你需要理解为何不建议,哪些场景有风险。

unsafe包同样是不安全的,但是很多场景我们都喜欢这个不安全。

chai2010 avatar Mar 27 '18 06:03 chai2010