← Back to context

Comment by higherhalf

2 years ago

> But rust absolutely does not have any C/C++ compatibilty besides [..]

> In zig you _can_ actually start with a c codebase and rewrite it file by file in zig and you _can_ include c headers in your zig files verbatim. Both of these are not possible in rust.

You can. Either via FFI and bindgen-ing headers, or by using c2rust. The latter is not just a toy ambitious project, but actually a very impressive piece of engineering and does produce a result where you can transpile a project or file and start rewriting file-by-file or function-by-function.

c2rust is definitely cool, but it also supports transpiling to a single architecture, which often misses a lot of architecture dependent code and specialisations in real world c code. Especially because it has to do macro expansion and you only get the expanded code.

It also doesn't supportal a good amount of more complicated c features.

It's a help for sure, but the few times I tried I ended up just doing the rewrite by hand instead to actually cover all the cases.