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 current version rather than the book version.
The Windows runtime support code has been written by Jean-Marc Lienher (cod5.org). The Darwin back-end and startup module have been contributed by Romain LWPB. Many thanks for the great effort!
The current version supports the following platforms:
(The book version runs on FreeBSD/386 exclusively.)
|stable||Regression tested before release. Should run on most versions of the OS.|
|untested||Not tested. May require some tweaking; may not run on all OS versions.|
|experimental||Work in progress. Expect lots of bugs.|
|broken||Known not to build. Substantial hacking required to fix.|
|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.
?:is an expression, not a logic op. (
a?b,c:dis a valid expression).
kprintf()function, which is like
fprintf(), but uses a file descriptor.
FILEs are now structs and can no longer be mistaken for
ints by the type checker.
jmp_bufis now a struct;
longjmp()must be called with
&jmp_buf(this is a bug).
registerkeywords are now recognized (as no-ops).
&arrayis now valid syntax (you no longer have to write