cxgo for Mac
CxGo is a tool for translating C source code to Go (aka transpiler, source-to-source compiler).
cxgo — overview
C to Go translator
CxGo is a tool for translating C source code to Go (aka transpiler, source-to-source compiler).
It uses cc v3 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: Implement a practical C to Go translator (no C++ for now). Keep the output program code correct. Make the generated code human-readable and as idiomatic as possible. 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: Potrace (image vectorization library) G722 (audio codec) PortableGL (OpenGL 3.x implementation) Physac (2D physics engine)
Installation
or download the latest release from Github.
How to use
The fastest way to try it is:
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
Details
将 C 转换为 Go
How to install cxgo
- Open Terminal (press ⌘ + Space and type “Terminal”).
- If Homebrew is not installed yet, run the command below first.
- Run this command:
Latest 10 releases
Last updated 2025-03-18; current version v0.5.2, with the latest 10 releases listed.
| Version | Released | Type | Size | macOS | Windows | Linux |
|---|---|---|---|---|---|---|
| v0.5.2 | 2025-03-18 | Stable | — | — | Download | Download |
| v0.5.1 | 2025-03-09 | Stable | — | — | Download | Download |
| v0.5.0 | 2025-03-01 | Stable | — | — | Download | Download |
| v0.4.3 | 2025-02-23 | Stable | — | — | Download | Download |
| v0.4.2 | 2025-02-22 | Stable | — | — | Download | Download |
| v0.4.1 | 2024-11-09 | Stable | — | — | Download | Download |
| v0.4.0 | 2024-07-06 | Stable | — | — | Download | Download |
| v0.3.7 | 2022-10-16 | Stable | — | — | — | Download |
| v0.3.6 | 2022-09-04 | Stable | — | — | — | Download |
| v0.3.5 | 2022-07-31 | Stable | — | — | — | Download |
Data from GitHub Releases; stable releases first, each group sorted newest first.
Compared with similar apps
Only public metadata is compared, with no subjective recommendation; see the compare pages for field-by-field comparisons.
| App | Version | License | Architecture | 30-day installs |
|---|---|---|---|---|
| cxgo | v0.5.2 | MIT | CLI | 0 |
| openssl@4 | openssl-4.1.0 | Apache-2.0 | CLI | 494,798 |
| xz | v5.8.4 | 0BSD AND GPL-2.0-or-later | CLI | 346,605 |
| pkgconf | pkgconf-3.0.10 | ISC | CLI | 311,054 |
Similar apps: Command-line Tools
openssl@4
Cryptography and SSL/TLS Toolkitxz
General-purpose data compression with high compression ratiopkgconf
pkgconf is a program which helps to configure compiler and linker flags for development…node
Node.js is an open-source, cross-platform JavaScript runtime environment.gh
GitHub command-line toolcmake
CMake is a cross-platform, open-source build system generator.Categories: Command-line Tools