cgo: implement support for static functions

This commit is contained in:
Ayke van Laethem
2022-04-13 21:34:43 +02:00
committed by Ron Evans
parent 91104b2f27
commit 5551ec7a1e
10 changed files with 131 additions and 22 deletions
+14
View File
@@ -3,4 +3,18 @@ package main
// Make sure CGo supports multiple files.
// int fortytwo(void);
// static float headerfunc_static(float a) { return a - 1; }
// static void headerfunc_void(int a, int *ptr) { *ptr = a; }
import "C"
func headerfunc_2() {
// Call headerfunc_static that is different from the headerfunc_static in
// the main.go file.
// The upstream CGo implementation does not handle this case correctly.
println("static headerfunc 2:", C.headerfunc_static(5))
// Test function without return value.
var n C.int
C.headerfunc_void(3, &n)
println("static headerfunc void:", n)
}