A transpiler that converts C source code into Go source code, enabling migration of C projects to Go.
c4go is a transpiler that converts C source code into Go source code. It parses C files using Clang and generates equivalent Go code, enabling developers to migrate C libraries and applications to Go. The tool handles C constructs like pointers, arrays, and standard library functions, producing runnable Go programs.
Developers and teams maintaining C codebases who want to transition to Go for improved safety, concurrency, or modern tooling. It's also useful for Go developers needing to integrate or understand legacy C libraries.
c4go provides a direct, automated path to translate C code to Go, reducing manual rewriting effort. It supports a wide range of C standard library functions and generates Go bindings automatically, making it practical for real-world projects.
Transpiling C code to Go code
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses Clang for parsing C code, ensuring accurate AST generation and handling complex syntax, as noted in the integration requirements.
Implements a substantial portion of the C standard library, with 100% coverage for headers like math.h, facilitating real-world translation.
Automatically adds Go bindings for missing C functions, such as frexp, reducing manual intervention in the translation process.
Aims to transpile significant projects like GNU GSL and GTK+, demonstrating practical application beyond toy examples.
Requires Clang installation, adding setup complexity and potential version conflicts, as emphasized in the prerequisites.
Transpilation can fail with errors like duplicate function definitions, necessitating manual code fixes, as shown in the neatvi example.
Generated code relies heavily on unsafe packages and helper functions like c4goUnsafeConvert, resulting in less readable and potentially unsafe Go.
Some C standard library headers have poor support, e.g., time.h at 6.67% and wchar.h at 5%, limiting translation for certain codebases.