github.com/comwrg/go/src@v0.0.0-20220319063731-c238d0440370/runtime/testdata/testwinlib/main.go (about)

     1  // +build windows,cgo
     2  
     3  package main
     4  
     5  // #include <windows.h>
     6  // typedef void(*callmeBackFunc)();
     7  // static void bridgeCallback(callmeBackFunc callback) {
     8  //	callback();
     9  //}
    10  import "C"
    11  
    12  // CallMeBack call backs C code.
    13  //export CallMeBack
    14  func CallMeBack(callback C.callmeBackFunc) {
    15  	C.bridgeCallback(callback)
    16  }
    17  
    18  // Dummy is called by the C code before registering the exception/continue handlers simulating a debugger.
    19  // This makes sure that the Go runtime's lastcontinuehandler is reached before the C continue handler and thus,
    20  // validate that it does not crash the program before another handler could take an action.
    21  // The idea here is to reproduce what happens when you attach a debugger to a running program.
    22  // It also simulate the behavior of the .Net debugger, which register its exception/continue handlers lazily.
    23  //export Dummy
    24  func Dummy() int {
    25  	return 42
    26  }
    27  
    28  func main() {}