ccgo/v1
Package ccgo translates cc ASTs to Go. (Work In Progress)
The v1 and v2 versions are no longer maintained. Please see the v3 version at
https://modernc.org/ccgo/v3
Installation
$ GO111MODULE=on go get -t -v -x modernc.org/ccgo/v3
After this, assuming binaries built by the Go downloader are on your $PATH, you should be able to run
$ ccgo hello.c -o hello.go
on a C “Hello, World” program and get an interesting result.
This directory also contains the older v2 and v1 versions. You almost certainly want the version in v3.
-
Compile hello.c
[email protected]:~/tmp> ll total 0 [email protected]:~/tmp> cat << EOF > hello.c #include <stdio.h> int main() { printf("Hello World!\n"); } EOF [email protected]:~/tmp> ccgo hello.c -o hello.go [email protected]:~/tmp> go run hello.go Hello World! [email protected]:~/tmp>
-
Run
$ go test -download
to (once) get required test resources. Add -dev for additional 100MB of gcc sources.