...

Source file src/runtime/testdata/testprogcgo/cgonocallback.go

Documentation: runtime/testdata/testprogcgo

     1  // Copyright 2023 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  package main
     6  
     7  // #cgo nocallback annotations for a C function means it should not callback to Go.
     8  // But it do callback to go in this test, Go should crash here.
     9  
    10  /*
    11  // TODO(#56378): #cgo nocallback runCShouldNotCallback
    12  extern void runCShouldNotCallback();
    13  */
    14  import "C"
    15  
    16  import (
    17  	"fmt"
    18  )
    19  
    20  func init() {
    21  	register("CgoNoCallback", CgoNoCallback)
    22  }
    23  
    24  //export CallbackToGo
    25  func CallbackToGo() {
    26  }
    27  
    28  func CgoNoCallback() {
    29  	C.runCShouldNotCallback()
    30  	fmt.Println("OK")
    31  }
    32  

View as plain text