Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

beluga: a standard C compiler

beluga is a standard C compiler being developed based on an earlier version of lcc. It supports C90 (to be precise, ISO/IEC 9899:1990) as its ancestor does and is planned to extend the coverage to C99 (and C11 finally).

Compared to its parent, beluga carefully implements the language standard and thus provides production-quality diagnostics including caret diagnostics, range highlighting, typedef preservation and macro expansion tracking:

screenshot for enhanced front-end features

The generated code is not highly optimized, but satisfactory enough for daily use. (This is a hobby project; never easy for me alone to catch up production compilers like gcc and clang+llvm.)

beluga currently produces assembly output for x86 only (and uses an assembler from the target system). Thanks to its origin, however, it can be readily retargeted to other platforms. Support for 64-bit machines (like x86-64) requires new significant features to be implemented and is one of most important goals of this project.

Also I'm redesigning each part of the compiler aiming for better structure (e.g., see below for an integrated preprocessor) and have a plan to completely replace the back-end interface and implementation to ease adoptation of more ambitious optimization techniques mainly based on a CFG.

An integrated preprocessor

The preprocessor formerly developed as a separate executable under the name of sea-canary, has been integrated into the compiler. It reads source code and delivers tokens (not characters) to the compiler proper via a token stream (not via a temporary file). It is fairly fast, is correct enough to pass many complicated test cases, produces highly compact output and has rich diagnostics. For example, it catches, with -Wtoken-paste-order option, code that subtly depends on an unspecified evaluation order of the ## operator like this:

#define concat(x, y, z) x ## y ## z
concat(3.14e, -, f)    /* non-portable */

and, due to the line mapper shared by the compiler, it pinpoints problematic spots as precisely as possible:

range highlighting on sub-expression from macro expansion

The current version conforms to C90, but supports features like empty arguments and variadic macros introduced in C99 and widely used now.

Try it out

You can try them out on the beluga's web page.

How to install explains how to build and install the package. For the copyright issues, see the accompanying file.


If you have a question or suggestion, do not hesitate to contact me via email (woong.jun at or web (


a standard C compiler (with an integrated preprocessor)







No releases published


No packages published