aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/cgo
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2018-11-30 12:45:38 +0100
committerAyke van Laethem <[email protected]>2018-12-10 15:38:03 +0100
commitc6069476a7d7f16bbd000004bf574a46d5d2222f (patch)
tree075a917dd973219f7845b93a148b94bbd1731f7e /testdata/cgo
parent0af7da9bff101070999cfe6a959f8c0791365243 (diff)
downloadtinygo-c6069476a7d7f16bbd000004bf574a46d5d2222f.tar.gz
tinygo-c6069476a7d7f16bbd000004bf574a46d5d2222f.zip
cgo: do not rely on stdint.h to be available
Diffstat (limited to 'testdata/cgo')
-rw-r--r--testdata/cgo/main.c8
-rw-r--r--testdata/cgo/main.go10
-rw-r--r--testdata/cgo/out.txt2
3 files changed, 7 insertions, 13 deletions
diff --git a/testdata/cgo/main.c b/testdata/cgo/main.c
index 0ce7b6831..ecee93178 100644
--- a/testdata/cgo/main.c
+++ b/testdata/cgo/main.c
@@ -1,13 +1,7 @@
-#include <stdint.h>
-
-int32_t fortytwo() {
+int fortytwo() {
return 42;
}
int add(int a, int b) {
return a + b;
}
-
-int32_t mul(int32_t a, int32_t b) {
- return a * b;
-}
diff --git a/testdata/cgo/main.go b/testdata/cgo/main.go
index f37c95eb9..f4a5d4d8b 100644
--- a/testdata/cgo/main.go
+++ b/testdata/cgo/main.go
@@ -1,20 +1,20 @@
package main
/*
-#include <stdint.h>
-int32_t fortytwo(void);
-int32_t mul(int32_t a, int32_t b);
-typedef int32_t myint;
+int fortytwo(void);
+typedef short myint;
int add(int a, int b);
*/
import "C"
+import "unsafe"
+
func main() {
println("fortytwo:", C.fortytwo())
- println("mul:", C.mul(C.int32_t(3), 5))
println("add:", C.add(C.int(3), 5))
var x C.myint = 3
println("myint:", x, C.myint(5))
+ println("myint size:", int(unsafe.Sizeof(x)))
var y C.longlong = -(1 << 40)
println("longlong:", y)
}
diff --git a/testdata/cgo/out.txt b/testdata/cgo/out.txt
index 5f222ce04..d6d208731 100644
--- a/testdata/cgo/out.txt
+++ b/testdata/cgo/out.txt
@@ -1,5 +1,5 @@
fortytwo: 42
-mul: 15
add: 8
myint: 3 5
+myint size: 2
longlong: -1099511627776