
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.
23 строки
332 Б
Go
23 строки
332 Б
Go
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
|
|
}
|