mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 03:27:48 +00:00
cgo: add support for stdio in picolibc and wasi-libc
This adds support for stdio in picolibc and fixes wasm_exec.js so that it can also support C puts. With this, C stdout works on all supported platforms.
This commit is contained in:
committed by
Ron Evans
parent
1645f45c1a
commit
14bb90c3c0
Vendored
+5
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
int fortytwo(void);
|
||||
#include "main.h"
|
||||
int mul(int, int);
|
||||
@@ -139,6 +140,10 @@ func main() {
|
||||
buf2 := make([]byte, len(buf1))
|
||||
C.strcpy((*C.char)(unsafe.Pointer(&buf2[0])), (*C.char)(unsafe.Pointer(&buf1[0])))
|
||||
println("copied string:", string(buf2[:C.strlen((*C.char)(unsafe.Pointer(&buf2[0])))]))
|
||||
|
||||
// libc: test basic stdio functionality
|
||||
putsBuf := []byte("line written using C puts\x00")
|
||||
C.puts((*C.char)(unsafe.Pointer(&putsBuf[0])))
|
||||
}
|
||||
|
||||
func printUnion(union C.joined_t) C.joined_t {
|
||||
|
||||
Vendored
+1
@@ -62,3 +62,4 @@ option 3A: 21
|
||||
enum width matches: true
|
||||
CFLAGS value: 17
|
||||
copied string: foobar
|
||||
line written using C puts
|
||||
|
||||
Reference in New Issue
Block a user