The compilation of incomplete C code can be useful in a variety of scenarios: debugging a snippet retrieved from a bug-tracking tool; running an static analysis on only part of a program; support editing features such as code-completion within an IDE; during cross-platform development when a header is incompatible; in order to generate data-structures straight out of algorithm implementations.

Psyche-c is a compiler for incomplete C code being developed in our lab. It receives as an input an incomplete, but syntactically valid, source code. This means that, if unexpanded macros are present, then those macros in unexpanded form must still conform to the C grammar rules. From this source, psyche-c produces a header file that, once plugged into the original file, leads to compilable code*.

To complete missing parts of programs, psyche-c solves several challenges. The first ones appear during parsing, since, not only syntax, but also semantic information (possibly absent) is required in C. Yet, the really cool challenges appear when we want to produce complete well-typed programs out of the partial ones. Give it a try! Despite being still under research, we can do pretty impressive things. psyche-c seems to be the first ever type inference for C. Its source is available at

* We don't generate function definitions, only declarations. Therefore, linking may not be possible.
- If necessary, you can preprocess your code with `gcc -E -P'.
- Our compiler is based on the C89 standard, with a few extensions.
- Variadic functions apart from those from the `printf' family are not yet supported.
- Only some of the C standard library functions have been implemented.

Check if the result is compilable with:
gcc clang kcc