fix: change clite's LLGoPackage to true to execute its init()

This commit is contained in:
Haolan
2025-09-10 14:14:22 +08:00
parent 0ed3a54244
commit 0bbdb6c204
4 changed files with 16 additions and 18 deletions

View File

@@ -21,7 +21,8 @@ import (
)
const (
LLGoPackage = "link"
// we want to execute init(), link / decl skips executing init()
LLGoPackage = true
)
type (

View File

@@ -18,9 +18,12 @@
package c
import _ "unsafe"
import (
_ "unsafe"
// initialized by z_print because LLGoPackage skips calling init()
var Stdin FilePtr
var Stdout FilePtr
var Stderr FilePtr
"github.com/goplus/lib/c"
)
var Stdin FilePtr = c.Fopen(c.Str("/dev/stdin"), c.Str("r"))
var Stdout FilePtr = c.Fopen(c.Str("/dev/stdout"), c.Str("w"))
var Stderr FilePtr = Stdout

View File

@@ -22,18 +22,6 @@ import (
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 {
if v {
return c.Str("true")