The SubC Compiler

SubC is a fast and simple public domain compiler for a clean subset of the C programming language. It can compile itself and passes gcc -Wall -pedantic. Its internals are described in detail in the book

Practical Compiler Construction

Note that SubC is a teaching vehicle rather than a production compiler. Check the README files to find out what it can and cannot do. If you are planning to do something more serious with SubC, you may want to get the development version rather than the book version.

Current book version (2nd edition): (~94KB), README, Fixes
Development version: subc-20220127.tgz (~129KB), README, Changes, Status
Experimental version: subc-20220127-typedef.tgz (~129KB), provides typedef, but widely untested, DOS support broken
Previous versions: subc-20161212.tgz (~120KB), subc-20140425b.tgz (~110KB)
DOS executables: (~140KB, experimental)
Old book version (1st edition): (~75KB), README
View the compiler sources online (2nd edition book version)
Check out Quan Tran's Go version of SubC
(most of the critical bugs mentioned by him have been fixed by now)

The Windows runtime support code has been written by Jean-Marc Lienher. The Darwin back-end and startup module have been contributed by Romain LWPB. The Linux/x86-64 and NetBSD/386 runtime support as well as proper signal handling for NetBSD were provided by Minux. Thank you!


The book version runs on FreeBSD/386 exclusively.
The development version supports the following platforms:

FreeBSD   386   armv6 x86-64
Linux   386     x86-64
NetBSD   386     x86-64
OpenBSD   (386)      
Windows/MinGW   386      
Darwin     (x86-64)
  DOS     8086      
stable Regression-tested before release. Should just work.
experimental Barely tested. Expect lots of bugs.
broken Known not to build. Might require substantial hacking.
(GLIBC) Uses GLIBC as a system call layer. Expect bugs!

No color? Please see the README in the archive for an ASCII rendition of the above table.

Major Changes since the Book Version

New Platforms

See above.


Language Level

contact  |  privacy