cgo: add //go: pragmas to generated functions and globals

This patch adds //go: pragmas directly to declared functions and
globals found during CGo processing. This simplifies the logic in the
compiler: it no longer has to consider special "C." prefixed function
names. It also makes the cgo pass more flexible in the pragmas it emits
for functions and global variables.
This commit is contained in:
Ayke van Laethem
2021-11-11 14:12:38 +01:00
committed by Ron Evans
parent a536ddcda8
commit 1789570f52
8 changed files with 108 additions and 49 deletions
+23
View File
@@ -0,0 +1,23 @@
package main
/*
// Function signatures.
int foo(int a, int b);
void variadic0();
void variadic2(int x, int y, ...);
// Global variable signatures.
extern int someValue;
*/
import "C"
// Test function signatures.
func accessFunctions() {
C.foo(3, 4)
C.variadic0()
C.variadic2(3, 5)
}
func accessGlobals() {
_ = C.someValue
}