aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/cgo
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2018-11-29 13:31:16 +0100
committerAyke van Laethem <[email protected]>2018-12-10 15:38:02 +0100
commitecf6ffa62ed45791362952caffefeffea4d96ed7 (patch)
tree068c79020c0c746a48ab1a4557aedb49686b18b4 /testdata/cgo
parentb99bbc880a154d2e8df153ae3da25c153f09cf87 (diff)
downloadtinygo-ecf6ffa62ed45791362952caffefeffea4d96ed7.tar.gz
tinygo-ecf6ffa62ed45791362952caffefeffea4d96ed7.zip
all: add bare-bones Cgo support
Diffstat (limited to 'testdata/cgo')
-rw-r--r--testdata/cgo/main.c9
-rw-r--r--testdata/cgo/main.go13
-rw-r--r--testdata/cgo/out.txt2
3 files changed, 24 insertions, 0 deletions
diff --git a/testdata/cgo/main.c b/testdata/cgo/main.c
new file mode 100644
index 000000000..315805aa4
--- /dev/null
+++ b/testdata/cgo/main.c
@@ -0,0 +1,9 @@
+#include <stdint.h>
+
+int32_t fortytwo() {
+ return 42;
+}
+
+int32_t mul(int32_t a, int32_t b) {
+ return a * b;
+}
diff --git a/testdata/cgo/main.go b/testdata/cgo/main.go
new file mode 100644
index 000000000..f2c5b533a
--- /dev/null
+++ b/testdata/cgo/main.go
@@ -0,0 +1,13 @@
+package main
+
+/*
+#include <stdint.h>
+int32_t fortytwo(void);
+int32_t mul(int32_t a, int32_t b);
+*/
+import "C"
+
+func main() {
+ println("fortytwo:", C.fortytwo())
+ println("mul:", C.mul(int32(3), 5))
+}
diff --git a/testdata/cgo/out.txt b/testdata/cgo/out.txt
new file mode 100644
index 000000000..e89fc9131
--- /dev/null
+++ b/testdata/cgo/out.txt
@@ -0,0 +1,2 @@
+fortytwo: 42
+mul: 15