cgo: implement struct types

Not complete: packed structs are treated as regular structs.
This commit is contained in:
Ayke van Laethem
2019-04-11 14:03:08 +02:00
committed by Ron Evans
parent bd8e47af80
commit 684543b7f1
4 changed files with 73 additions and 4 deletions
+1
View File
@@ -8,6 +8,7 @@ double globalDouble = 3.2;
_Complex float globalComplexFloat = 4.1+3.3i;
_Complex double globalComplexDouble = 4.2+3.4i;
_Complex double globalComplexLongDouble = 4.3+3.5i;
collection_t globalStruct = {256, -123456, 3.14};
int fortytwo() {
return 42;
+1
View File
@@ -36,6 +36,7 @@ func main() {
println("complex float:", C.globalComplexFloat)
println("complex double:", C.globalComplexDouble)
println("complex long double:", C.globalComplexLongDouble)
println("struct:", C.globalStruct.s, C.globalStruct.l, C.globalStruct.f)
}
//export mul
+7
View File
@@ -5,6 +5,12 @@ int doCallback(int a, int b, binop_t cb);
typedef int * intPointer;
void store(int value, int *ptr);
typedef struct collection {
short s;
long l;
float f;
} collection_t;
// test globals
extern int global;
extern _Bool globalBool;
@@ -14,6 +20,7 @@ extern double globalDouble;
extern _Complex float globalComplexFloat;
extern _Complex double globalComplexDouble;
extern _Complex double globalComplexLongDouble;
extern collection_t globalStruct;
// test duplicate definitions
int add(int a, int b);