github.com/riscv/riscv-go@v0.0.0-20200123204226-124ebd6fcc8e/misc/cgo/errors/issue13830.go (about)

     1  // Copyright 2016 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // cgo converts C void* to Go unsafe.Pointer, so despite appearances C
     6  // void** is Go *unsafe.Pointer. This test verifies that we detect the
     7  // problem at build time.
     8  
     9  package main
    10  
    11  // typedef void v;
    12  // void F(v** p) {}
    13  import "C"
    14  
    15  import "unsafe"
    16  
    17  type v [0]byte
    18  
    19  func f(p **v) {
    20  	C.F((**C.v)(unsafe.Pointer(p))) // ERROR HERE
    21  }
    22  
    23  func main() {
    24  	var p *v
    25  	f(&p)
    26  }