Skip to content

Chinese++ 0.1

Choose a tag to compare

@YoloLogic YoloLogic released this 26 Sep 21:18
· 18 commits to main since this release

Chinese++ 0.1 — 首个发行包

Windows x64,x86_64-pc-windows-msvc。

作者个人理解的完美的汉语编程。

#包含 <cstdio>          // 中文指令,等价于 #include
#include <vector>        // 英文指令 —— 混着写没问题

整数 主函数() {                       // 主函数 = main
    std::vector<int> 数字{1, 2, 3};   // 库名仍是英文
    整数 和 = 0;
    对于 (整数 n : 数字)              // 对于 = for
        和 += n;
    std::printf("和 = %d\n", 和);
    返回 0;                           // 返回 = return
}

包含什么

  • 基于修改过的 Clang/LLVM 24.0.0git 构建的工具链
  • 99 条中文关键字拼写、22 条中文预处理指令、7344 / 7374 条中文诊断正文
  • 主函数 与 main 是同一个标识符
  • 英文拼写一律保留、行为不变;改动不涉及任何 Diagnostic*.td

⚠️ 第 1 步:先装 Visual Studio 的 C++ 组件(必须,别跳过)

已经装过 Visual Studio、且勾了「使用 C++ 的桌面开发」的 —— 跳过这一步。

三条路,挑一条:

# 最快:一行命令
winget install --id Microsoft.VisualStudio.2022.BuildTools --override "--quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"

下载约 2 GB,装完约占 6 GB,需要管理员权限,需要几分钟。

为什么必须装? 本工具链不自带标准库 —— C++ 标准库(std::vector、std::string…)、C 运行库、Windows SDK 都是微软的东西,没有权利把它们打包分发。

这也是一件好事:正因为用的是微软原封不动的 MSVC STL,本编译器编出来的东西和官方 clang / MSVC 编出来的二进制兼容,可以互相链接,现成的第三方库照用。

没装的症状:编译时报 找不到文件(名字) 'cstdio'。看到「找不到文件」这类错,十有八九就是这一条。


第 2 步:下载并解压本页附件

见本页最下方 Assets 区块 —— 它可能是折叠的,点一下展开才能看到 Chinese++-0.1-win64.zip。

解压后双击 一键安装.cmd:

  • 重建 9 个硬链接别名(clang.exe、clang-cl.exe、lld.exe…)
  • 生成 env.cmd —— 窗口级 PATH 设置器,不碰你的永久 PATH
  • 检查 Visual Studio Build Tools,缺了就打印确切要装什么
  • 把官方 VS Code 下载到本目录的 .\vscode\,用便携模式配好(中文语言包 + clangd),你自己装的那个 VS Code 一个字节都不动
  • 编译并运行一个中文 hello world,证明它真的能用

需要联网(下载 VS Code 约 320 MB)。断网了就重新双击一次,已装好的部分不会重装。

第 3 步:验证

powershell -File verify.ps1

它会从包内真编一个中文 hello world。过了就是能用。
不确定 Visual Studio 装没装,也可以先跑它 —— 它会告诉你缺什么。


说明

  • 本仓库只发布发行包,源码不公开
  • LLVM 派生内容依 Apache-2.0 WITH LLVM-exception 分发,许可证正文见仓库内 LICENSE.TXT
  • 改动声明与第三方说明见 NOTICE.txt
  • 详细文档:常见问题.md 与 中文对照表.md
  • 不是微软官方产品,与 Microsoft 无隶属或背书关系

English

First release (Windows x64, x86_64-pc-windows-msvc).

Chinese++ is a modified LLVM/Clang 24.0.0git toolchain that makes Chinese keywords a
first-class spelling
in C++. English keywords still work, and the two can be mixed freely.

  • 99 Chinese keyword spellings, 22 Chinese preprocessor directives, 7344/7374 translated diagnostics
  • 主函数 is the same identifier as main
  • The standard library deliberately keeps its English names

⚠️ The MSVC STL and Windows SDK are not bundled. Install Visual Studio Build Tools with the C++
workload first:

winget install --id Microsoft.VisualStudio.2022.BuildTools --override "--quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"

or grab the direct installer /
Visual Studio Community (tick
"Desktop development with C++"). Otherwise compilation fails with file not found: 'cstdio'.

Then download Chinese++-0.1-win64.zip from the Assets section below, extract it, run
一键安装.cmd, and run verify.ps1 to prove it works.

Distributed under Apache-2.0 WITH LLVM-exception — see LICENSE.TXT and NOTICE.txt in the
repository. Not a Microsoft product.

2026-10-06 重打(同一个 v0.1 标签,替换了 zip 资产)

这一版把「汉语库」真正做进了包里,并把 GUI 第四轨道推进到 GDI / 控件 / 菜单:

  • 汉化库随包:zhstdlib\(119 个中文头:标准库 48 / 别名 43 / C运行库 25 / windows系统 3)
    ⇒ 解压装好后 #包含 <向量> 开箱可用;tools\ 里的两个脚本负责把搜索路径写进 bin\*.cfg。
  • GUI 中文名:<窗口>(窗口类/消息/控件/菜单)+ 新头 <绘图>(GDI:设备上下文/画笔/画刷/
    填充/画矩形/画椭圆/画线/输出文本/无效化矩形/设备能力 …)。要链 user32.lib / gdi32.lib。
  • compiler-rt:12 个运行库(ASan/UBSan/覆盖率)+ 4 个 ignorelist + 20 个接口头
    (<sanitizer/asan_interface.h> 可用)。
  • 安装时自动写搜索路径:bin\chinese++.cfg / clang++.cfg / clang.cfg
    ⇒ 命令行与编辑器(clangd)都不必再记那 5 条 -isystem;移动包后重跑一次一键安装即可。
  • 自测:包内 verify.ps1 = 21 passed, 0 failed(含 ASan 真报 use-after-free、--coverage、
    中文关键字、以及"不带任何 -I 也能编中文头"那一段)。
    已在中文路径与另一盘符各验一遍;最小 PATH(只剩 system32)下也能编能跑。
  • 已知前提:本工具链需要机器上装 Visual Studio 生成工具(MSVC STL 与 Windows SDK 不在包里)。