The following is a list of open source compilers that can generate C (or in some cases, C++) code.
Project name/link | Language(s) supported | Notes |
---|---|---|
ATS | ATS | Applied Type System (ATS) is a statically typed programming language that unifies implementation with formal specification. It is equipped with a highly expressive type system rooted in it. In particular, both dependent types and linear types are available in it. |
B::C | Perl 5 | This compiler backend takes Perl source and generates C source code corresponding to the internal structures that perl uses to run your program. |
BaCon (Basic Converter) | Basic | BaCon is a free BASIC to C translator for Unix-based systems, which runs on most Unix/Linux/BSD platforms, including MacOSX. It intends to be a programming aid in creating tools which can be compiled on different platforms (including 64bit environments), while trying to revive the days of the good old BASIC. |
bc9Basic | Basic | Can generate C or C++ code. Runs only on Windows but can generate code for *nix. A fork of BCX that outputs valid ISO/ANSI C. Website archive. |
Bigloo | Scheme (R5RS) | Bigloo is a Scheme native-code compiler. It compiles Scheme code down to C, JVM bytecode or .NET bytecode. It includes type annotations, a unique object-oriented system based on CLOS, the Common Lisp Object System, and runtime performance is very close to C. |
Blech | Blech | A synchronous programming language for embedded reactive real-time-critical software. |
bmx-ng | BlitzMax | A Monkey-derived BlitzMax to C transpiler. |
Carp | Lisp (Carp) | A statically typed lisp, without a GC, for real-time applications. |
CFortranTranslator | Fortran | A translator from Fortran90/Fortran77(ISO/IEC 1539:1991) to C++, Not C. |
Chapel | Chapel | Chapel is a programming language designed for productive parallel computing on large-scale systems. Chapel's design and implementation have been undertaken with portability in mind, permitting Chapel to run on multicore desktops and laptops, commodity clusters, and the cloud, in addition to the high-end supercomputers for which it was designed. It can generate optimized C code. |
CHICKEN Scheme | Scheme (R5RS) | |
Ciao | Prolog | Ciao is a general purpose, multi-paradigm programming language in the Prolog family. The compiler can generate a .c file for each .pl file. |
cito | Ć | A language for making portable libraries with a syntax like C#. Also targets Java, C#, JavaScript, ActionScript, Perl 5 and D. |
CLiCC | Common Lisp | Compiles a large strict subset of Common Lisp + CLOS to C. |
Critical Mass Modula-3 | Modula-3 | CM3 is the first open source release of the Modula-3 compiler and bundled software from Critical Mass,Inc. |
Cyclone | Scheme (R7RS) | Cheney on the M.T.A. with native threads. |
Cython | Python | |
Céu | Céu | It provides Structured Synchronous Reactive Programming. The compiler converts an input program in Céu to an output in C. |
eC | eC | An object-oriented superset of C with modules and generics. |
EiffelStudio | Eiffel | |
Embeddable Common-Lisp | ANSI Common Lisp | |
Emfrp | Emfrp | A pure functional reactive programming language for small-scale embedded systems. |
Emgo | Go | Compiles a subset of Go for 32-bit microcontrollers through C. |
Epic | Epic | Epic is a simple functional Supercombinator language which compiles to reasonably efficient C code. It is currently used as a back end for Idris. |
Esotope Brainfuck Compiler | Brainfuck | |
Euphoria to C Translator | Euphoria | |
f2c | Fortran 77 | F2c converts Fortran 77 source code in files with names ending in .f' or .F' to C (or C++) source files. |
f90toC | Fortran 90 | A Fortran 90 to C compiler. Note: This is a development version. It is not ready for general use as a Fortran compiler. |
fable | Fortran 77 | Automatic fixed-format Fortran sources to C++ conversion, not C. |
FortranToCplusplus | Fortran 90 | A C++ program that reads a Fortran 90 program and translates into a logically equivalent C++ program, not C. |
Felix | Felix | Targets C++, not C. |
FreeBASIC | Basic | A BASIC compiler for Microsoft Windows, DOS and Linux. It provides a high level of support for programs written for QuickBASIC. It is a self-hosting compiler that can produce console, graphical/GUI executables, dynamic and static libraries. It supports C libraries, style preprocessor, capable of multiline macros, conditional compiling and file inclusion, and C++ library partial. Programmers use and create libraries for C and many other languages. It can compile into intermediate file(s), eg. .asm, .c, .ll . |
Futhark | Futhark | Purely functional data-parallel language generating OpenCL C |
Gambit | Scheme (R5RS) | The Gambit Scheme system is a complete, portable, efficient and reliable implementation of the Scheme programming language. It consists of two main programs: interpreter and compiler that generates portable C code. It conforms to the R4RS, R5RS and IEEE Scheme standards and implements all optional features. |
GCL | Common Lisp | GCL is the official Common Lisp for the GNU project. Its design makes use of the system's C compiler to compile to native object code. |
Genie | Genie | Genie is another programming language supported by the Vala compiler with a syntax closer to Python. |
GHC | Haskell | C backend documentation page. |
GnuCOBOL | COBOL 2014 with extensions | The compiler can translate COBOL source files are into C files. |
gp2c | PARI/GP | the GP-to-C compiler, combines the best of both worlds by compiling GP scripts to the C language and transparently loading the resulting functions into gp. |
Hexa | like JavaScript | JavaScript-inspired syntax and behavior, Compiles to JavaScript, WebAssembly, osdev, LLVM, C, C++, ObjC, etc.. |
Haxe | Haxe | Has separate C++ and C targets. Compilation to C is done using HashLink transpiler (HL/C). |
Idris | Idris | A pure functional programming language with dependent types. |
Ivory | Ivory | A Haskell eDSL for safe systems programming. |
IL2C | C# / CIL / MSIL | - A translator for ECMA-335 CIL/MSIL to C language. |
jhc | Haskell 98 | The resulting code doesn't use a garbage collector. |
JX Objective-C | Objective-C (JX Dialect) | Object-oriented (Kayian School) language hosted on C |
Kit | Kit | A statically typed procedural language with manual MM, traits, pattern matching, and metaprogramming designed with game development in mind. |
Language84 | Language84 | Language 84 is a programming language with a self-hosting compiler. |
mbeddr | mbeddr | A set of languages for embedded software engineering. |
matiec (unoffficial mirror) | ST, IL, SFC (IEC 61131) | A set of textual languages for PLC programming. The iec2c compiler generates ANSI C code which is equivalent to the IEC 61131-3 code expressed in the input file. |
Mercury | Mercury(~Prolog) | Mercury is a logic/functional programming language which combines the clarity and expressiveness of declarative programming with advanced static analysis and error detection features. It produce intermediate C code. |
M (Mosaic) | M (inspired by Algol-68) | M is a systems language first devised for 8-bit Z80 systems in early 1980s, since evolved and now targeting 64-bit Windows machines using x64 processor. It builds to a single executable file that I usually call mm.exe, currently some 0.6MB, which includes a small set of libraries. (That is, the sources for the libraries are part of the executable.) This gives a tidy self-contained compiler. |
MLton | Standard ML | MLton is an optimizing Standard ML compiler, Supports the full SML 97 language specification. It can compile to C code. |
Monkey 2 | Monkey 2 | Targets C++, not C. |
Mrustc | Rust | This project is an attempt at creating a simple rust compiler into intermidate C code. |
NectarJS | JavaScript | The primary target is WebAssembly. How to compile to C. |
Nelua | Lua | Nelua, stands for Native Extensible Lua, is a minimalistic, efficient, optionally typed, ahead of time compiled, meta programmable, systems programming language with syntax and semantics similar to Lua. It can work statically or dynamically depending on the code style and compiles to native machine code. Nelua compiles to C first then to the target native code. compiling on Windows is done using WSL or msys2. |
Nim | Nim | Can generate C, C++ or Objective C code. |
Nit | Nit | it is an expressive Object Oreinted language with a script-like syntax, a friendly type-system and aims at elegance, simplicity and intuitiveness. The syntax of Nit follows the Pascal tradition and is inspired by various script languages (especially Ruby). Its main objective is readability. |
NN-512 | NN-512 graph language | Generate C99 code for neural net inference. |
Nuitka | Python | |
OBNC | Oberon | is a compiler implementation the latest version of the Oberon Prgramming language from 2016. OBNC translates source code written in Oberon to the lower-level programming language C. |
ocamlcc | OCaml | Compiles OCaml bytecode to C. |
oi | C with traits | Compiles to code that can be directly used from plain C. |
ooc | ooc | is a small programming language with a clear and concise syntax that compiles to C99. |
OpenDylan | Dylan | Dylan is a multi-paradigm programming language that includes support for functional and object-oriented programming (OOP), and is dynamic and reflective while providing a programming model designed to support generating efficient machine code, including fine-grained control over dynamic and static behaviors. It generate intermidate C code. |
p2c | Several Pascal dialects, including UCSD and Turbo Pascal; Modula-2. | Can generate C or C++ code. |
ParparVM | Java bytecode | Use for the Java to iOS portability part of the Codename One project. |
perlcc | Perl 5 | Generate C code, and compiles to executables, from Perl programs |
pd_compiler | Pure Data | Pure Data compiler, translates pd files into C code for compilation on embedded systems. Presently targeting ARM Cortex-M4F microcontrollers. |
prometeo | Python | An experimental Python-to-C transpiler and domain specific language for embedded high-performance computing |
purescript-native | PureScript | Targets C++, not C. |
Py14 | Python | Targets C++, not C. |
Pythran | Python | Targets C++, not C. |
Ragel | Ragel | Can generate C or C++ code. Compiles executable finite state machines from regular languages. |
RPerl | RPerl, a restricted subset of Perl. | Targets C++, not C. Unrelated to RPython. |
RPython | RPython, a restricted subset of Python. | Unrelated to RPerl. |
Sather | Sather | Sather is an object oriented language which is designed to be simple, efficient, safe, and non-proprietary. It aims to foster the development of a large, freely available, high-quality library of efficient well-written classes for a wide variety of computational tasks. It was originally based on Eiffel, incorporating ideas and approaches from several languages. Sather code can be compiled into C code and can efficiently link with C object files. |
Scheme-to-C | Scheme | Example nanopass compiler |
Seed7 | Seed7 | Seed7 is a general purpose programming language that new statements and operators can be declared easily. Functions with type results and type parameters are more elegant than a template or generics concept. Object orientation is used where it brings advantages and not in places where other solutions are more obvious. The compiler translates Seed7 programs to C programs. |
Shedskin | Python | Targets C++, not C. |
SLua | Lua | Static lua compiler - Compile Lua code into C code. |
SystemTap | SystemTap scripting language | SystemTap compiles kernel modules for monitoring Linux systems. |
ThinScript | ThinScript | A lower-level programming language inspired by TypeScript. ThinScript also compiles to JavaScript and WebAssembly. |
ts2c | JavaScript, TypeScript | Compiles a subset of JavaScript/TypeScript (ES3) to readable C89. |
TSP | A typed subset of Tcl. | An experimental JIT. Compiles procedures written in a statically typed subset of Tcl to C or Java to accelerate Tcl programs. |
UbxBasic | Basic | Can generate C or C++ code. A fork of BCX that adds Linux support in addition to Windows. Uses Glib. |
Ur/Web | Ur/Web | Ur is a programming language in the tradition of ML and Haskell, but featuring a significantly richer type system. Ur is functional, pure, statically typed, and strict. Ur supports a powerful kind of metaprogramming based on row types. Ur/Web is Ur plus a special standard library and associated rules for parsing and optimization. Ur/Web supports construction of dynamic web applications backed by SQL databases. |
V | V | Simple, fast, safe, compiled language for developing maintainable software. V can translate your entire C project and offer you the safety, simplicity, and 10-25x compilation speed-up. |
Vala | Vala | Vala is a programming language using modern high level abstractions without imposing additional runtime requirements and without using a different ABI compared to applications and libraries written in C. Vala uses the GObject type system and has additional code generation routines that make targeting the GNOME stack simple. |
Vostok | Oberon-07 | Also targets Java, JavaScript, Oberon dialects, and Plant UML Activity Diagrams. |
wasm2c | WebAssembly | Converts WASM files to C source and header. |
wasmdec | WebAssembly | Converts WebAssembly binaries to C. Note: the demo shows a WAST code converted to C code. |
wax | wax | A language design for transpiling. Compiles to C, C#, C++, Java, Lua, Python, Swift, TypeScript, and WebAssembly. |
Zephir | Zephir | A language for writing PHP extensions. |
ZZ | ZZ (Drunk Octopus) | A safe dialect of C for embedded systems inspired by Rust. |
- C-Mera, a simple source-to-source compiler that transforms s-expression notation to code in a C-family language.
- LISP/c, a Common Lisp-based macrolanguage for C.
- Cello, a library for high-level programming in C.
- Dynace, a portable, open-source object-oriented extension to the C, inspired by smalltalk and CLOS.
- Object Oriented C (ooc) kit is for those who want to program in an object orieneted manner, but stick on the good old C as well. ooc implements classes, single and multiple inheritance, exception handling.
- Clue, an ANSI C compiler targeting high level languages (Lua, JavaScript, Perl 5, C, Java, Common Lisp).
- LLVM C backend resurrected.
- luastatic, a tool that builds standalone executables from Lua programs by embedding Lua code in C.
Your contributions are welcome! Please submit a pull request or create an issue to add a new compiler to the list.