Created
December 10, 2021 21:06
-
-
Save ibd1279/1edb2726f69dbd17f77a8a7657c790b4 to your computer and use it in GitHub Desktop.
Simple program that converts a uint32 to a pointer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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