Skip to content

Instantly share code, notes, and snippets.

@ibd1279
Created December 10, 2021 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibd1279/1edb2726f69dbd17f77a8a7657c790b4 to your computer and use it in GitHub Desktop.
Save ibd1279/1edb2726f69dbd17f77a8a7657c790b4 to your computer and use it in GitHub Desktop.
Simple program that converts a uint32 to a pointer.
package main
import (
"fmt"
"unsafe"
)
import "C"
func main() {
for h := 0; h < 100000; h++ {
a := uint32(1053)
b := &a
c := unsafe.Pointer(b)
d := (*C.ulong)(c)
e := *d
f := C.ulong(a)
if e != f {
fmt.Printf("%d iteration : %d, %p, %p, %p, %d, %d\n", h, a, b, c, d, e, f)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment