{"id":13413010,"url":"https://github.com/goplus/c2go","last_synced_at":"2025-03-14T19:30:53.905Z","repository":{"id":37033951,"uuid":"474068444","full_name":"goplus/c2go","owner":"goplus","description":"Convert C to Go","archived":true,"fork":false,"pushed_at":"2024-05-18T11:23:51.000Z","size":795,"stargazers_count":307,"open_issues_count":13,"forks_count":21,"subscribers_count":9,"default_branch":"main","last_synced_at":"2024-07-31T20:51:47.946Z","etag":null,"topics":["c","c2go","go","golang","gop","goplus","programming-language"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goplus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-25T15:38:59.000Z","updated_at":"2024-05-18T11:24:15.000Z","dependencies_parsed_at":"2023-09-30T12:31:26.503Z","dependency_job_id":"0baa9f08-4660-4984-afe0-8dbdc2b989d7","html_url":"https://github.com/goplus/c2go","commit_stats":null,"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goplus%2Fc2go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goplus%2Fc2go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goplus%2Fc2go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goplus%2Fc2go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goplus","download_url":"https://codeload.github.com/goplus/c2go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221495322,"owners_count":16832459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","c2go","go","golang","gop","goplus","programming-language"],"created_at":"2024-07-30T20:01:32.298Z","updated_at":"2024-10-26T04:31:34.439Z","avatar_url":"https://github.com/goplus.png","language":"Go","funding_links":[],"categories":["HarmonyOS","Go 编译器","Go Compilers","Go"],"sub_categories":["Windows Manager","检索及分析资料库","Search and Analytic Databases","Advanced Console UIs"],"readme":"c2go - Convert C to Go\n========\n\n[![Build Status](https://github.com/goplus/c2go/actions/workflows/go.yml/badge.svg)](https://github.com/goplus/c2go/actions/workflows/go.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/goplus/c2go)](https://goreportcard.com/report/github.com/goplus/c2go)\n[![GitHub release](https://img.shields.io/github/v/tag/goplus/c2go.svg?label=release)](https://github.com/goplus/c2go/releases)\n[![Coverage Status](https://codecov.io/gh/goplus/c2go/branch/main/graph/badge.svg)](https://codecov.io/gh/goplus/c2go)\n[![GoDoc](https://pkg.go.dev/badge/github.com/goplus/c2go.svg)](https://pkg.go.dev/mod/github.com/goplus/c2go)\n[![Language](https://img.shields.io/badge/language-Go+-blue.svg)](https://github.com/goplus/gop)\n\nThis project is **DEPRECATED**! We are shifting our technical roadmap to [llgo](https://github.com/goplus/llgo).\n\nThis is a subproject of [the Go+ project](https://github.com/goplus/gop). Its goal is converting any C project into Go without any human intervention and keeping performance close to C.\n\n* Make it passed. Stage: `Done Almost`. We have compiled [libc](https://github.com/goplus/libc) (in progress) and [sqlite3](https://github.com/goplus/sqlite-c2go) (done).\n* Make it correct. Stage: `Doing`. We ported `libc-test` to test [c2go](https://github.com/goplus/c2go) and [libc](https://github.com/goplus/libc). Coverage: [![Coverage Status](https://codecov.io/gh/goplus/libc/branch/musl-go/graph/badge.svg)](https://codecov.io/gh/goplus/libc)\n* Make it fast. Stage: `Planning`.\n\n![Screen Shot1](https://user-images.githubusercontent.com/396972/160951673-30ec62ae-2981-4cdf-a1ab-bc7fcb6f7475.png)\n\n\n## How to run examples?\n\nRun an example:\n\n- Build c2go tools: `go install -v ./...`\n- Go `testdata/xxx` directory, and run `c2go .`\n\nRun/Test multiple examples:\n\n- Run examples: `c2go ./...`\n- Test examples: `c2go -test ./...`\n\n\n## How c2go is used in Go+\n\nHere is [an example to show how Go+ interacts with C](https://github.com/goplus/gop/tree/main/testdata/helloc2go).\n\n```go\nimport \"C\"\n\nC.printf C\"Hello, c2go!\\n\"\nC.fprintf C.stderr, C\"Hi, %7.1f\\n\", 3.14\n```\n\nHere 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:\n\n```go\nimport \"C/github.com/goplus/libc\"\n\nC.printf C\"Hello, c2go!\\n\"\nC.fprintf C.stderr, C\"Hi, %7.1f\\n\", 3.14\n```\n\nIn 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).\n\nRun `gop run .` to see the output of this example:\n\n```\nHello, c2go!\nHi,     3.1\n```\n\n## What's our plan?\n\n- First, support most of the syntax of C. Stage: `Done Almost`, see [supported C syntax](#supported-c-syntax).\n- Second, compile `sqlite3` to fix c2go bugs and get list of its dependent C standard libary fuctions. Stage: `Done`, see [github.com/goplus/sqlite](https://github.com/goplus/sqlite) and [its dependent fuctions](https://github.com/goplus/sqlite/blob/main/c2go_autogen.go).\n- Third, support most of C standard library functions (especially that used by `sqlite3`), and can import them by Go+. Stage: `Doing`, see [detailed progress here](https://github.com/goplus/libc#whats-our-plan).\n- Last, support all custom libraries, especially those well-known open source libraries. Stage: `Planning`.\n\n\n## Tested Platform\n\n- [x] MacOS: 11.x\n- [x] Linux: ubuntu-20.04 (temporarily skip `testdata/qsort`)\n- [ ] Windows\n\n\n## Supported C syntax\n\n### Data structures\n\n- [x] Void: `void`\n- [x] Boolean: `_Bool`, `bool`\n- [x] Integer: [`signed`/`unsigned`] [`short`/`long`/`long long`] `int`\n- [x] Enum: `enum`\n- [x] Float: `float`, `double`, `long double`\n- [x] Character: [`signed`/`unsigned`] `char`\n- [ ] Wide Character: `wchar_t`\n- [ ] Large Integer: [`signed`/`unsigned`] `__int128`\n- [x] Complex: `_Complex` `float`/`double`/`long double`\n- [x] Typedef: `typedef`\n- [x] Pointer: *T, T[]\n- [x] Array: T[N], T[]\n- [x] Array Pointer: T(*)[N]\n- [x] Function Pointer: T (*)(T1, T2, ...)\n- [x] Struct: `struct`\n- [x] Union: `union`\n- [x] BitField: `intType :N`\n\n### Operators\n\n- [x] Arithmetic: a+b, a-b, a*b, a/b, a%b, -a, +a\n- [x] Increment/Decrement: a++, a--, ++a, --a\n- [x] Comparison: a\u003cb, a\u003c=b, a\u003eb, a\u003e=b, a==b, a!=b\n- [x] Logical: a\u0026\u0026b, a||b, !a\n- [x] Bitwise: a|b, a\u0026b, a^b, ~a, a\u003c\u003cn, a\u003e\u003en\n- [x] Pointer Arithmetic: p+n, p-n, p-q, p++, p--\n- [x] Assignment: `=`\n- [x] Operator Assignment: a`\u003cop\u003e=`b\n- [x] BitField Assignment: `=`\n- [ ] BitField Operator Assignment: a`\u003cop\u003e=`b\n- [x] Struct/Union/BitField Member: a.b\n- [x] Array Member: a[n]\n- [x] Pointer Member: \u0026a, *p, p[n], n[p], p-\u003eb\n- [x] Comma: `a,b`\n- [x] Ternary Conditional: cond?a:b\n- [x] Function Call: f(a1, a2, ...)\n- [x] Conversion: (T)a\n- [x] Sizeof: sizeof(T), sizeof(a)\n- [x] Offsetof: __builtin_offsetof(T, member)\n\n### Literals\n\n- [x] Boolean, Integer\n- [x] Float, Complex Imaginary\n- [x] Character, String\n- [x] Array: `(T[]){ expr1, expr2, ... }`\n- [x] Array Pointer: `\u0026(T[]){ expr1, expr2, ... }`\n- [x] Struct: `struct T{ expr1, expr2, ... }`\n\n### Initialization\n\n- [x] Basic: `T a = expr`\n- [x] Array: `T a[] = { expr1, expr2, ... }`, `T a[N] = { expr1, expr2, ... }`\n- [x] Struct: `struct T a = { expr1, expr2, ... }`, `struct T a = { .a = expr1, .b = expr2, ... }`\n- [x] Union: `union T a = { expr }, union T a = { .a = expr }`\n- [x] Array in Struct: `struct { T a[N]; ... } v = { { expr1, expr2, ... }, ... }`, `struct { T a[N]; ... } v = { { [0].a = expr1, [1].a = expr2, ... }, ... }`\n\n### Control structures\n\n- [x] If: `if (cond) stmt1 [else stmt2]`\n- [x] Switch: `switch (tag) { case expr1: stmt1 case expr2: stmt2 default: stmtN }`\n- [x] For: `for (init; cond; post) stmt`\n- [x] While: `while (cond) stmt`\n- [x] Do While: `do stmt while (cond)`\n- [x] Break/Continue: `break`, `continue`\n- [x] Goto: `goto label`\n\n### Functions\n\n- [x] Parameters\n- [x] Variadic Parameters\n- [x] Variadic Parameter Access\n- [x] Return\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoplus%2Fc2go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoplus%2Fc2go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoplus%2Fc2go/lists"}