mirror of
https://github.com/goplus/llgo.git
synced 2025-09-26 19:51:21 +08:00

- Consolidate _demo, _pydemo, _embdemo into single _demo directory structure - Organize demos by language: _demo/{go,py,c,embed}/ - Categorize demos based on imports: - Python library demos (py imports) → _demo/py/ - C/C++ library demos (c/cpp imports) → _demo/c/ - Go-specific demos → _demo/go/ - Embedded demos → _demo/embed/ - Move C-related demos (asm*, cabi*, cgo*, linkname, targetsbuild) from go/ to c/ - Update all path references in README.md and GitHub workflows - Improve demo organization and navigation as requested in #1256 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
32 lines
571 B
Go
32 lines
571 B
Go
package main
|
|
|
|
import (
|
|
_ "unsafe"
|
|
|
|
"github.com/goplus/lib/c"
|
|
)
|
|
|
|
//go:linkname write C.write
|
|
func write(c.Int, *c.Char, c.SizeT) int
|
|
|
|
func main() {
|
|
buf := c.Malloc(6)
|
|
c.Memset(buf, 0, 6)
|
|
c.Strncpy((*c.Char)(buf), c.Str("abcde"), 5)
|
|
|
|
if c.Strcmp((*c.Char)(buf), c.Str("abcde")) == 0 {
|
|
write(1, c.Str("pass strcmp"), 11)
|
|
}
|
|
|
|
if byte(c.Index((*c.Char)(buf), 0)) == 'a' {
|
|
write(1, c.Str("pass index"), 10)
|
|
}
|
|
|
|
c.Memset(buf, c.Int('A'), 5)
|
|
if c.Strcmp((*c.Char)(buf), c.Str("AAAAA")) == 0 {
|
|
write(1, c.Str("pass memeset"), 11)
|
|
}
|
|
|
|
write(1, (*c.Char)(buf), 5)
|
|
}
|