github.com/laevusdexter/asmcgocall@v0.0.0-20200220061330-f484a47e9b97/examples/single_return.go (about)

     1  package main
     2  
     3  /*
     4  
     5  int ret_value = 666;
     6  
     7  int single_ret(int *ret) {
     8  
     9  	*ret = ret_value;
    10  
    11  	// error code
    12  	return 0;
    13  }
    14  
    15  int regular_single_ret() {
    16  	return ret_value;
    17  }
    18  
    19  */
    20  import "C"
    21  
    22  import "github.com/LaevusDexter/asmcgocall"
    23  
    24  var singleRetExpected = C.ret_value
    25  
    26  var singleRetAsmcgocall = func() (result func() C.int) {
    27  	asmcgocall.Register(C.single_ret, &result)
    28  
    29  	return
    30  }()
    31  
    32  func singleRetCgocall() C.int {
    33  	return C.regular_single_ret()
    34  }