Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
memetea opened this issue Mar 27, 2018 · 1 comment
Open

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

memetea opened this issue Mar 27, 2018 · 1 comment

Comments

@memetea
Copy link
Collaborator

memetea commented Mar 27, 2018

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)

@chai2010
Copy link
Owner

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants