# QPCC — an experimental C compiler written in Moonbit, supporting most of C23, C2Y, and a subset of GCC extensions.

**URL:** <https://discuss.moonbitlang.com/t/qpcc-an-experimental-c-compiler-written-in-moonbit-supporting-most-of-c23-c2y-and-a-subset-of-gcc-extensions/508>\
**Category:** General\
**Created:** [December 1, 2026, 3:30am UTC](https://discuss.moonbitlang.com/t/qpcc-an-experimental-c-compiler-written-in-moonbit-supporting-most-of-c23-c2y-and-a-subset-of-gcc-extensions/508 "2026-12-01T03:30:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![azhzx](https://discuss.moonbitlang.com/user_avatar/discuss.moonbitlang.com/azhzx/32/409_2.png) [@azhzx](https://discuss.moonbitlang.com/u/azhzx)\
**Post date:** [December 1, 2026, 3:30am UTC](https://discuss.moonbitlang.com/t/qpcc-an-experimental-c-compiler-written-in-moonbit-supporting-most-of-c23-c2y-and-a-subset-of-gcc-extensions/508/1 "2026-12-01T03:30:44Z")

</div>

QPCC — an experimental C compiler written in Moonbit, supporting most of C23, C2Y, and a subset of GCC extensions.

Its backend is qbe.mbt, a compiler backend project also implemented in Moonbit.

QPCC has successfully compiled QBE (a C project). It performed differential testing between the binary built by QPCC and the binary compiled from the same sources by Clang, passing all 58 out of 58 tests.

Experimental C2Y features implemented include named loops, \_Countof, \_Maxof, \_Minof, and \_Defer.

Upcoming roadmap: add \_Atomic support, introduce a compiler syntax extension for \_Tagged\_union, and expand the test suite.

Limitations: support for K&R C and some obscure legacy syntax is incomplete.

Difference from mbtcc: mbtcc only targets C11, and it fails to build under the latest Moonbit compiler.

---

<div class="post-metadata">

**Author:** ![rachelthompson](https://discuss.moonbitlang.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@rachelthompson](https://discuss.moonbitlang.com/u/rachelthompson)\
**Post date:** [December 1, 2026, 1:34pm UTC](https://discuss.moonbitlang.com/t/qpcc-an-experimental-c-compiler-written-in-moonbit-supporting-most-of-c23-c2y-and-a-subset-of-gcc-extensions/508/2 "2026-12-01T13:34:42Z")

</div>

For the differential testing against Clang, were the 58 tests comparing only runtime behavior, or also diagnostics and exit codes for invalid programs? Compiler bugs often surface on error paths, so a negative-test set would make the comparison stronger. Also, how does \_Defer interact with early returns and goto within the same scope?
