immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.95k stars 234 forks source link

Readme example of transpile for main.c doesn't work #1052

Closed cameronelliott closed 9 months ago

cameronelliott commented 9 months ago

I'm quite excited about c2rust, thanks for making it.

My issue is c2rust is failing when I pass it a simple C program.

c@macmini ~/D/r/rsync-vanilla (master)> c2rust transpile main.c
thread 'main' panicked at /Users/c/.cargo/registry/src/index.crates.io-6f17d22bba15001f/c2rust-transpile-0.18.0/src/lib.rs:234:9:
Could not parse compile commands from /Users/c/Documents/rsync/rsync-vanilla/main.c
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
c@macmini ~/D/r/rsync-vanilla (master) [101]>

I presume c2rust is trying to read main.c like it is expecting a json compile_commands.json file.

But it seems like c2rust transpile main.c should work like the example in the Readme: https://github.com/immunant/c2rust/blob/master/README.md?plain=1#L156

Is direct use of .c and .h supported?

Did I make a mistake.

kkysen commented 9 months ago

Hi! That functionality to directly transpile a file without a compile commands was added recently, so it's only on master, not released on crates.io yet. So you'd have to install c2rust with cargo install c2rust --git https://github.com/immunant/c2rust.