fix: println

This commit is contained in:
Haolan
2025-09-05 19:00:53 +08:00
parent e444c4b6ac
commit 7ca8abc788
3 changed files with 18 additions and 5 deletions

View File

@@ -20,10 +20,7 @@ package c
import _ "unsafe" import _ "unsafe"
//go:linkname Stdin stdin // initialized by z_print because LLGoPackage skips calling init()
var Stdin FilePtr var Stdin FilePtr
//go:linkname Stdout stdout
var Stdout FilePtr var Stdout FilePtr
var Stderr FilePtr
var Stderr FilePtr = Fopen(Str("/dev/stderr"), Str("w"))

View File

@@ -2,6 +2,10 @@
package runtime package runtime
import (
_ "unsafe"
)
const ( const (
LLGoPackage = "link" LLGoPackage = "link"
LLGoFiles = "_wrap/runtime.c" LLGoFiles = "_wrap/runtime.c"

View File

@@ -22,6 +22,18 @@ import (
c "github.com/goplus/llgo/runtime/internal/clite" c "github.com/goplus/llgo/runtime/internal/clite"
) )
func init() {
if c.Stdin == nil {
c.Stdin = c.Fopen(c.Str("/dev/stdin"), c.Str("r"))
}
if c.Stdout == nil {
c.Stdout = c.Fopen(c.Str("/dev/stdout"), c.Str("w"))
}
if c.Stderr == nil {
c.Stderr = c.Stdout
}
}
func boolCStr(v bool) *c.Char { func boolCStr(v bool) *c.Char {
if v { if v {
return c.Str("true") return c.Str("true")