Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
W

wgtcc

> 编程语言
Open source

A small C11 compiler

773 stars0 likes1 views
WebsiteGitHub

About

A small C11 compiler

wgtcc

A small C11 compiler in C++11.

Environment

  1. x86-64
  2. linux 4.4.0
  3. clang 3.8.0 (or any version supports C++11)

Build

bash
cmake . -Bbuild
cd build && make && make test

Install

bash
make install

Then you can play with the examples:

bash
wgtcc example/heart.c
wgtcc example/chinese.c

Without Install

Try this:

bash
./wgtcc -no-pie -I../include ../example/heart.c

Notice

As wgtcc doesn't support PIC/PIE, if you are using gcc >= 6.2.0, specify -no-pie explicitly:

bash
wgtcc -no-pie example/heart.c
wgtcc -no-pie example/chinese.c

Goal

wgtcc is aimed to implement the full C11 standard with some exceptions:

  1. Some features are supported only in grammar level(like keyword register).
  2. Features that disgusting me are removed (like default int type without type specifier).
  3. Some non standard GNU extensions are supported, but you should not rely on wgtcc of a full supporting.

Front End

A basic recursive descent parser.

Back End

wgtcc generates code from AST directly. The algorithm is TOSCA (top of stack caching). It is far from generating efficient code, but at least it works and generates code efficently.

Memory Management

Through wgtcc was written in C++, I paid no effort for memory management except for a simple memory pool to accelerate allocations. only new is preferred because wgtcc runs fast and exits immediately after finishing parsing and generating code.

Reference

  1. Compilers Principles, Techniques and Tools. Second Edition.
  2. N1548, C11 standard draft
  3. 64-ia-32-architectures-software-developer-manual-325462
  4. 8cc
  5. 9c
  6. macro expansion algorithm

Todo

  • support GNU extensions (e.g. keyword __attribute__)
  • support variable length array
  • optimization (e.g. register allocation)
  • support type qualification

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++assemblyc11compilerscpp11

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言