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 5package main 6 7/* 8extern int *GoFn(int *); 9 10// Yes, you can have definitions if you use //export, as long as they are weak. 11int f(void) __attribute__ ((weak)); 12 13int f() { 14 int i; 15 int *p = GoFn(&i); 16 if (*p != 12345) 17 return 0; 18 return 1; 19} 20*/ 21import "C" 22 23//export GoFn 24func GoFn(p *C.int) *C.int { 25 *p = C.int(12345) 26 return p 27} 28 29func main() { 30 if r := C.f(); r != 1 { 31 panic(r) 32 } 33} 34