Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: Native C to Go compiler #41518

Closed
ivanjaros opened this issue Sep 21, 2020 · 2 comments
Closed

Q: Native C to Go compiler #41518

ivanjaros opened this issue Sep 21, 2020 · 2 comments

Comments

@ivanjaros
Copy link

I have been forced to work with C libraries since there are no alternatives in Go and it is quite a pain, especially on Windows. And I don't want to be moving to Rust or C itself. I even begun trying to port some C to Go but it was just way too much code to do by hand with uncertain end result so I abandoned that idea. Anyway, I was wondering if there is a chance/way/plan... to have Go be able to take C code and simply translate it into Go code so we won't have to use CGo at all? C is simpler than Go so a compiler/transcoder should be, in theory, able to make a Go version from C's AST. The only problematic parts are the manual memory management that C code has to do but I am sure that could be solved by smart minds behind Go.

So is this in the realm of possibility or just a wishful thinking?

@mvdan
Copy link
Member

mvdan commented Sep 21, 2020

Some people have built this externally, see https://github.com/elliotchance/c2go. I seem to remember that https://godoc.org/modernc.org/sqlite is mostly C translated to Go to avoid CGo, as well.

In general, I don't see why this should live inside the Go project itself. If you have a piece of software that translates C to Go, you can just publish the resulting Go on a source repository, or build it directly.

Also, please remember that the Go project doesn't use the issue tracker for questions. See https://golang.org/wiki/Questions.

@mvdan
Copy link
Member

mvdan commented Sep 21, 2020

You gave a thumbs up, so I assume the question is answered or you're happy moving to one of the forums, like golang-nuts. Closing this for now.

@mvdan mvdan closed this as completed Sep 21, 2020
@golang golang locked and limited conversation to collaborators Sep 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants