Chris's Wiki :: blog/programming/GoUintptrVsUnsafePointer Commentshttps://utcc.utoronto.ca/~cks/space/blog/programming/GoUintptrVsUnsafePointer?atomcommentsDWiki2018-02-12T04:47:52ZRecent comments in Chris's Wiki :: blog/programming/GoUintptrVsUnsafePointer.By Fred Akalin on /blog/programming/GoUintptrVsUnsafePointertag:CSpace:blog/programming/GoUintptrVsUnsafePointer:b7b13870ad95d6f06798d891c7912e7f494c3323Fred Akalin<div class="wikitext"><p>The magic that lets cgo store pointers to C objects in unsafe.Pointer isn't too magical. The go runtime knows where the go heap is, and simply ignores all others. I think the rule is that unsafe.Pointer must be a valid pointer, but not necessarily one to a Go object.</p>
<p>See <a href="https://groups.google.com/forum/#!msg/golang-nuts/ls7Eg7Ye9pU/ye1GLs8dBwAJ">https://groups.google.com/forum/#!msg/golang-nuts/ls7Eg7Ye9pU/ye1GLs8dBwAJ</a> and <a href="https://github.com/golang/go/issues/21897#issuecomment-330338879">https://github.com/golang/go/issues/21897#issuecomment-330338879</a> for authoritative-ish sources.</p>
</div>2018-02-12T04:47:52ZBy lilydjwg on /blog/programming/GoUintptrVsUnsafePointertag:CSpace:blog/programming/GoUintptrVsUnsafePointer:fa12a2a736a3bb769e0055757454de22753bd369lilydjwg<div class="wikitext"><p>IMO it's easier to think uintptr as an unsigned pointer-sized integer type, like usize in Rust. The name is confusing.</p>
</div>2018-01-19T06:55:39Z