A new better C language for my fantasy, a better programing world for void !
一个新的 “better C” 语言,给void一个更好的编程世界!
“Empty your mind, be formless, shapeless, like water. You put water into a cup, it becomes the cup; you put it into a bottle, it becomes the bottle; you put it into a teapot, it becomes the teapot. Now water can flow, or it can crash. Be water, my friend.”
— Bruce Lee
NiHao
A new better C language for my fantasy, a better programing world for void !
一个新的 “better C” 语言,给void一个更好的编程世界!
“Empty your mind, be formless, shapeless, like water. You put water into a cup, it becomes the cup; you put it into a bottle, it becomes the bottle; you put it into a teapot, it becomes the teapot. Now water can flow, or it can crash. Be water, my friend.” — Bruce Lee
“清空你的思绪,无形无相,如水一般。
水入杯,则成杯形;入瓶,则成瓶形;入茶壶,则成茶壶之形。
水可缓缓流淌,亦可奔涌冲击。
像水一样吧,我的朋友。”
— 李小龙
语法文档|Document
中文 | English
开发约定|Development Conventions
Git 提交与推送约定 · 版本路线图(1.0/2.0) · 进度总结 · TODO · 变更日志
Source code example demonstration:
源码展示:
安装 | Installation
1. 安装 xmake
构建依赖 xmake(唯一构建入口,Makefile 已标为 legacy):
2. 安装 tcc(编译器后端依赖)
NihaoC 1.0 的
c/native后端依赖 TinyCC(tcc 负责把生成的 C 编译为机器码):C:\dev\tcc),设置环境变量NIHAO_TCC_DIR=C:\dev\tcc;未设置时从PATH探测。MSYS 路径(/d/devtools/tcc)会自动归一化sudo apt install tcc(或pacman -S tcc),-run内存执行与libtcc.so均可用tcc -v能看到版本号即可构建与运行 | Build & Run
编译器源码位于
ncc/,构建统一使用 xmake:CLI 命令 | Commands
init [name]nihao.toml+src/main.nc)build <file><out>.c中间产物)run <file>--之后的参数透传给main(argc, argv)debug <file>--ir打印 IR 三地址码(2.0 预览)testtests/)lex <file>常用选项:
-o <file>输出名 ·-backend c|native选择后端 ·-run(Linux only)内存执行 ·-g调试信息 ·-I/-L/-l头文件/库路径与链接 ·--link <lib> as <alias>链接别名。后端 | Backends
c(默认)nativeir-c/ir-nativeir-riscv64ir-arm64ir-loongarch64TCC 安装目录通过
NIHAO_TCC_DIR环境变量指定(如/d/devtools/tcc,MSYS 路径自动归一化),否则从 PATH 探测。-run内存执行(Linux only)-run将程序编译到内存并直接执行,仅 Linux 可用:TCC_OUTPUT_MEMORY存在缺陷(relocate 失败,错误码 251)-run会得到明确报错;请改用-backend=native -o out.exe输出文件模式native_memory_available()完成(Windows 返回 0,其余平台返回 1)-run之后直接透传给main(argc, argv)(PA-6)