cgo: only include the symbols that are necessary (recursively)

Only try to convert the C symbols to their Go equivalents that are
actually referenced by the Go code with C.<somesymbol>. This avoids
having to support all possible C types, which is difficult because of
oddities like `typedef void` or `__builtin_va_list`. Especially
__builtin_va_list, which varies between targets.
This commit is contained in:
Ayke van Laethem
2019-04-27 23:26:20 +02:00
committed by Ron Evans
parent 35af33ead7
commit b1ed8a46b7
3 changed files with 137 additions and 57 deletions
+6
View File
@@ -2,12 +2,17 @@
#include <stdint.h>
typedef short myint;
typedef short unusedTypedef;
int add(int a, int b);
int unusedFunction(void);
typedef int (*binop_t) (int, int);
int doCallback(int a, int b, binop_t cb);
typedef int * intPointer;
void store(int value, int *ptr);
// this signature should not be included by CGo
void unusedFunction2(int x, __builtin_va_list args);
typedef struct collection {
short s;
long l;
@@ -37,6 +42,7 @@ void unionSetData(short f0, short f1, short f2);
// test globals and datatypes
extern int global;
extern int unusedGlobal;
extern bool globalBool;
extern bool globalBool2;
extern float globalFloat;