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; supporting code-completion within an IDE; during cross-platform development when a header is incompatible; or 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 a snippet[1]. From it, psyche-c produces a header file that, once #included into the original program, leads to compilable code[2].

To complete the missing parts of programs, psyche-c solves several challenges. The first ones appear during parsing, which in C requires, not only syntax, but also semantic information. Yet, the really cool challenges appear during type inference. Is 0 an integer or the null pointer? How to account for const/volatile in implicit conversions (particularly through poitners)? What about variadic functions? And the subtyping relation involving void*? Psyche-c is still under research, but you can give it a try. Its source is available at https://github.com/ltcmelo/psychec.

[1] In this online version, if an expanded macro is present, then it must conform to the C grammar (i.e. be syntactically valid).
[2] We don't generate function definitions, only declarations. Therefore, linking may not be possible.
- To preprocess your code you can run GCC/Clang with `gcc -E -P'.
- Ensure the code is valid: start with a compilable program, then gradually strip it off.


Check if the result is compilable with:
gcc clang