This project is DEPRECATED! We are shifting our technical roadmap to llgo.
This is a subproject of the Go+ project. Its goal is converting any C project into Go without any human intervention and keeping performance close to C.
Done Almost
. We have compiled libc (in progress) and sqlite3 (done).Doing
. We ported libc-test
to test c2go and libc. Coverage: Planning
.Run an example:
go install -v ./...
testdata/xxx
directory, and run c2go .
Run/Test multiple examples:
c2go ./...
c2go -test ./...
Here is an example to show how Go+ interacts with C.
import "C"
C.printf C"Hello, c2go!\n"
C.fprintf C.stderr, C"Hi, %7.1f\n", 3.14
Here we use import "C"
to import libc. It's an abbreviation for import "C/github.com/goplus/libc"
. It is equivalent to the following code:
import "C/github.com/goplus/libc"
C.printf C"Hello, c2go!\n"
C.fprintf C.stderr, C"Hi, %7.1f\n", 3.14
In this example we call two C standard functions printf
and fprintf
, passing a C variable stderr
and two C strings in the form of C"xxx"
(a Go+ syntax to represent C style strings).
Run gop run .
to see the output of this example:
Hello, c2go!
Hi, 3.1
Done Almost
, see supported C syntax.sqlite3
to fix c2go bugs and get list of its dependent C standard libary fuctions. Stage: Done
, see github.com/goplus/sqlite and its dependent fuctions.sqlite3
), and can import them by Go+. Stage: Doing
, see detailed progress here.Planning
.testdata/qsort
)void
_Bool
, bool
signed
/unsigned
] [short
/long
/long long
] int
enum
float
, double
, long double
signed
/unsigned
] char
wchar_t
signed
/unsigned
] __int128
_Complex
float
/double
/long double
typedef
struct
union
intType :N
=
<op>=
b=
<op>=
ba,b
(T[]){ expr1, expr2, ... }
&(T[]){ expr1, expr2, ... }
struct T{ expr1, expr2, ... }
T a = expr
T a[] = { expr1, expr2, ... }
, T a[N] = { expr1, expr2, ... }
struct T a = { expr1, expr2, ... }
, struct T a = { .a = expr1, .b = expr2, ... }
union T a = { expr }, union T a = { .a = expr }
struct { T a[N]; ... } v = { { expr1, expr2, ... }, ... }
, struct { T a[N]; ... } v = { { [0].a = expr1, [1].a = expr2, ... }, ... }
if (cond) stmt1 [else stmt2]
switch (tag) { case expr1: stmt1 case expr2: stmt2 default: stmtN }
for (init; cond; post) stmt
while (cond) stmt
do stmt while (cond)
break
, continue
goto label