Hi golang-nuts,

I would like to call a C function from Go and get notified about the 
execution status in Go, say a goroutine wait until the C function finally 
made some progress.
Initially, I thought about passing a channel to C but the cgo document does 
not say anything about that:

Later, I am thinking about using an atomic variable to sync status 
according to its value, but somehow I end up with this warning while I am 
compiling a cgo program:

package main

/*
#include <stdatomic.h>
void ainit(atomic_int *val) {
    atomic_init(val, 0);
}
*/
import "C"

func main() {
    var v C.atomic_int
    C.ainit(&v)
}

cgo-gcc-prolog: In function ‘_cgo_8a67e594de48_Cfunc_ainit’:
cgo-gcc-prolog:49:14: warning: passing argument 1 of ‘ainit’ from 
incompatible pointer type [-Wincompatible-pointer-types]
./main.go:5:24: note: expected ‘_Atomic atomic_int *’ {aka ‘_Atomic int *’} 
but argument is of type ‘int *’
    5 | void ainit(atomic_int *val) {
      |            ~~~~~~~~~~~~^~~

According to the warning and note, it seems that cgo is lacking translating 
atomic_init? Did I do anything wrong? Or is there any better and preferred 
way to get notified from C function?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b4e8b7c7-015d-4b9e-80ef-e49c07bea301n%40googlegroups.com.

Reply via email to