Created
April 17, 2019 12:07
-
-
Save madwizard/05fdbf3f128f883bec90c07648e585ea to your computer and use it in GitHub Desktop.
Mapping C struct to go
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
func wirelessScan() int { | |
p := C.malloc(unsafe.Pointer(C.wireless_scan_head{})) | |
defer C.free(p) | |
iface := C.CString("wlp4s0") | |
sk := iwSocketsOpen() | |
weVersion := getKernelWEVersion() | |
ret := int(C.iw_process_scan(_Ctype_int(sk), iface, _Ctype_int(weVersion), unsafe.Pointer(p))) | |
return ret | |
} | |
Returned error: | |
dwojslaw ~ GolandProjects gowifiscanner go run main.go wifi.go | |
# command-line-arguments | |
./wifi.go:36:39: cannot convert _Ctype_struct_wireless_scan_head literal (type _Ctype_struct_wireless_scan_head) to type unsafe.Pointer | |
./wifi.go:43: cannot use unsafe.Pointer(p) (type unsafe.Pointer) as type *_Ctype_struct_wireless_scan_head in argument to func literal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment