All Projects → gotranspile → cxgo

gotranspile / cxgo

Licence: MIT license
Tool for transpiling C to Go.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to cxgo

Rbql
🦜RBQL - Rainbow Query Language: SQL-like language for (not only) CSV file processing. Supports SQL queries with Python and JavaScript expressions
Stars: ✭ 118 (-49.57%)
Mutual labels:  transpiler
Rockstar Js
JavaScript transpiler for the esoteric language 'Rockstar'
Stars: ✭ 189 (-19.23%)
Mutual labels:  transpiler
sherlock.py
Sherlock is transpiler that translate python to shell script language.
Stars: ✭ 65 (-72.22%)
Mutual labels:  transpiler
Webpack Babel Env Deps
Find dependencies to transpile with Babel.
Stars: ✭ 130 (-44.44%)
Mutual labels:  transpiler
Aesara
Aesara is a fork of the Theano library that is maintained by the PyMC developers. It was previously named Theano-PyMC.
Stars: ✭ 145 (-38.03%)
Mutual labels:  transpiler
Plus
This project is being developed privately.
Stars: ✭ 215 (-8.12%)
Mutual labels:  transpiler
Crossshader
⚔️ A tool for cross compiling shaders. Convert between GLSL, HLSL, Metal Shader Language, or older versions of GLSL.
Stars: ✭ 113 (-51.71%)
Mutual labels:  transpiler
sbt-babel
An SBT plugin to perform Babel compilation.
Stars: ✭ 12 (-94.87%)
Mutual labels:  transpiler
C2rust
Migrate C code to Rust
Stars: ✭ 2,111 (+802.14%)
Mutual labels:  transpiler
C4go
Transpiling C code to Go code
Stars: ✭ 253 (+8.12%)
Mutual labels:  transpiler
Rosid
Just-in-time development server and static site generator.
Stars: ✭ 139 (-40.6%)
Mutual labels:  transpiler
Rapydscript Ng
A transpiler for a Python like language to JavaScript
Stars: ✭ 140 (-40.17%)
Mutual labels:  transpiler
Retyped
Access 3600+ libraries from C# and let Bridge.NET compile your project into JavaScript.
Stars: ✭ 216 (-7.69%)
Mutual labels:  transpiler
C2go
⚖️ A tool for transpiling C to Go.
Stars: ✭ 1,736 (+641.88%)
Mutual labels:  transpiler
elephize
Typescript to PHP translation tool
Stars: ✭ 27 (-88.46%)
Mutual labels:  transpiler
Ply
Painless polymorphism
Stars: ✭ 117 (-50%)
Mutual labels:  transpiler
Transcrypt
Python 3.7 to JavaScript compiler - Lean, fast, open! -
Stars: ✭ 2,502 (+969.23%)
Mutual labels:  transpiler
dragon
Dragon is a universal Python translater.
Stars: ✭ 26 (-88.89%)
Mutual labels:  transpiler
dotlin
Kotlin to Dart compiler
Stars: ✭ 212 (-9.4%)
Mutual labels:  transpiler
Moonscript
🌙 A language that compiles to Lua
Stars: ✭ 2,694 (+1051.28%)
Mutual labels:  transpiler

C to Go translator

GitHub license Gitter GoDoc

CxGo is a tool for translating C source code to Go (aka transpiler, source-to-source compiler).

It uses cc for preprocessing and parsing C (no clang/gcc dependencies!) and a custom type-checker and AST translation layer to make the best output possible.

The only requirement is: C code must compile with cxgo, including headers.

Having said that, cxgo uses a few tricks to make this process easier.

TL;DR for the project goals:

  1. Implement a practical C to Go translator (no C++ for now).
  2. Keep the output program code correct.
  3. Make the generated code human-readable and as idiomatic as possible.
  4. Make it easy to use and customize.

Check the FAQ for more common question about the project.

Status

The project is experimental! Do not rely on it in production and other sensitive environments!

Although it was successfully tested on multiple projects, it might change the behavior of the code due to yet unknown bugs.

Compiler test results:

  • TCC: 62/89 (70%)
  • GCC: 783/1236 (63%)

Transpiled projects:

Installation

go get -u github.com/gotranspile/cxgo/cmd/cxgo

or download the latest release from Github.

How to use

The fastest way to try it is:

cxgo file main.c

For more details, check our examples section.

It will guide you through basic usage patterns as well as a more advanced ones (on real-world projects).

You may also check FAQ if you have any issues.

Caveats

The following C features are currently accepted by cxgo, but may be implemented partially or not implemented at all:

  • preserving comments from C code (#2)
  • static (#4)
  • auto (#5)
  • bitfields (#6)
  • union with C-identical data layout (#7)
  • packed structs (#8)
  • asm
  • case in weird places (#9)
  • goto forbidden by Go (there is a workaround, though, see #10)
  • label variables (#11)
  • thread local storage (#12)
  • setjmp (will compile, but panics at runtime)
  • some stdlib functions and types are missing (good first issue!)
  • deep type inference (when converting to Go string/slices)
  • considering multiple #ifdef paths for different OS/envs

Community

Join our community! We'd like to hear back from you!

Contributing

See CONTRIBUTING.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].