aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2019-04-20 15:48:45 +0200
committerRon Evans <[email protected]>2019-04-25 10:48:56 +0200
commitb815d3f7609ebbda502a611e4be77a5f5da019ae (patch)
treeb2da4b39686118cdf395e4789ac5133257ec8679 /testdata
parent9c46ac4eed1356ee3feb7e2e10fcc6c7c8a80103 (diff)
downloadtinygo-b815d3f7609ebbda502a611e4be77a5f5da019ae.tar.gz
tinygo-b815d3f7609ebbda502a611e4be77a5f5da019ae.zip
cgo: implement void* pointer type
void* is translated to unsafe.Pointer on the Go side.
Diffstat (limited to 'testdata')
-rw-r--r--testdata/cgo/main.c2
-rw-r--r--testdata/cgo/main.go2
-rw-r--r--testdata/cgo/main.h2
-rw-r--r--testdata/cgo/out.txt1
4 files changed, 7 insertions, 0 deletions
diff --git a/testdata/cgo/main.c b/testdata/cgo/main.c
index 1d144a021..6f52749fc 100644
--- a/testdata/cgo/main.c
+++ b/testdata/cgo/main.c
@@ -9,6 +9,8 @@ _Complex float globalComplexFloat = 4.1+3.3i;
_Complex double globalComplexDouble = 4.2+3.4i;
_Complex double globalComplexLongDouble = 4.3+3.5i;
char globalChar = 100;
+void *globalVoidPtrSet = &global;
+void *globalVoidPtrNull;
collection_t globalStruct = {256, -123456, 3.14, 88};
int globalStructSize = sizeof(globalStruct);
short globalArray[3] = {5, 6, 7};
diff --git a/testdata/cgo/main.go b/testdata/cgo/main.go
index ae95943a2..0e85fc099 100644
--- a/testdata/cgo/main.go
+++ b/testdata/cgo/main.go
@@ -41,6 +41,8 @@ func main() {
println("complex double:", C.globalComplexDouble)
println("complex long double:", C.globalComplexLongDouble)
println("char match:", C.globalChar == 100)
+ var voidPtr unsafe.Pointer = C.globalVoidPtrNull
+ println("void* match:", voidPtr == nil, C.globalVoidPtrNull == nil, (*C.int)(C.globalVoidPtrSet) == &C.global)
// complex types
println("struct:", C.int(unsafe.Sizeof(C.globalStruct)) == C.globalStructSize, C.globalStruct.s, C.globalStruct.l, C.globalStruct.f)
diff --git a/testdata/cgo/main.h b/testdata/cgo/main.h
index 8c09fe9b7..a7b3b75a2 100644
--- a/testdata/cgo/main.h
+++ b/testdata/cgo/main.h
@@ -37,6 +37,8 @@ extern _Complex float globalComplexFloat;
extern _Complex double globalComplexDouble;
extern _Complex double globalComplexLongDouble;
extern char globalChar;
+extern void *globalVoidPtrSet;
+extern void *globalVoidPtrNull;
extern collection_t globalStruct;
extern int globalStructSize;
extern short globalArray[3];
diff --git a/testdata/cgo/out.txt b/testdata/cgo/out.txt
index df481edf7..2e799e60b 100644
--- a/testdata/cgo/out.txt
+++ b/testdata/cgo/out.txt
@@ -15,6 +15,7 @@ complex float: (+4.100000e+000+3.300000e+000i)
complex double: (+4.200000e+000+3.400000e+000i)
complex long double: (+4.300000e+000+3.500000e+000i)
char match: true
+void* match: true true true
struct: true 256 -123456 +3.140000e+000
array: 5 6 7
union: true