github.com/MangoDowner/go-gm@v0.0.0-20180818020936-8baa2bd4408c/misc/cgo/testsanitizers/msan3.go (about) 1 // Copyright 2015 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 /* 8 extern int *GoFn(int *); 9 10 // Yes, you can have definitions if you use //export, as long as they are weak. 11 int f(void) __attribute__ ((weak)); 12 13 int f() { 14 int i; 15 int *p = GoFn(&i); 16 if (*p != 12345) 17 return 0; 18 return 1; 19 } 20 */ 21 import "C" 22 23 //export GoFn 24 func GoFn(p *C.int) *C.int { 25 *p = C.int(12345) 26 return p 27 } 28 29 func main() { 30 if r := C.f(); r != 1 { 31 panic(r) 32 } 33 }