mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 04:23:41 +00:00
cgo: implement struct types
Not complete: packed structs are treated as regular structs.
This commit is contained in:
committed by
Ron Evans
parent
bd8e47af80
commit
684543b7f1
Vendored
+1
@@ -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;
|
||||
|
||||
Vendored
+1
@@ -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
|
||||
|
||||
Vendored
+7
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user