-
Notifications
You must be signed in to change notification settings - Fork 248
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
Can't compile c2rust
-generated program using rustc
#661
Comments
That C code doesn't compile either, as it declares Also, the reason I'm not quite sure about the |
The C code compiles fine using gcc compiler. |
also even when using cargo it throws whole bunch of errors. Here's the C file: void main() {
// printf() displays the string inside quotation
printf("Hello, World!");
} Here's the converted rust file by c2rust: #![allow(dead_code, mutable_transmutes, non_camel_case_types, non_snake_case,
non_upper_case_globals, unused_assignments, unused_mut)]
#![register_tool(c2rust)]
#![feature(main, register_tool)]
extern "C" {
#[no_mangle]
fn printf(_: *const libc::c_char, _: ...) -> libc::c_int;
}
unsafe fn main_0() {
// printf() displays the string inside quotation
printf(b"Hello, World!\x00" as *const u8 as *const libc::c_char);
}
#[main]
pub fn main() { unsafe { main_0() } ::std::process::exit(0i32); } Here's the complete set of errors. ┌──(pegasus㉿pegasus)-[~/Documents/Rust_testing]
└─$ cargo build --all
warning: crate `Rust_testing` should have a snake case name
|
= note: `#[warn(non_snake_case)]` on by default
= help: convert the identifier to snake case: `rust_testing`
warning: `Rust_testing` (bin "Rust_testing") generated 1 warning
Compiling Rust_testing v0.1.0 (/home/pegasus/Documents/Rust_testing)
error[E0557]: feature has been removed
--> src/bin/converted_hello.rs:4:12
|
4 | #![feature(main, register_tool)]
| ^^^^ feature has been removed
error: cannot find attribute `main` in this scope
--> src/bin/converted_hello.rs:13:3
|
13 | #[main]
| ^^^^
|
= note: `main` is in scope, but it is a function, not an attribute
warning: `#[no_mangle]` has no effect on a foreign function
--> src/bin/converted_hello.rs:6:1
|
6 | #[no_mangle]
| ^^^^^^^^^^^^ help: remove this attribute
7 | fn printf(_: *const libc::c_char, _: ...) -> libc::c_int;
| --------------------------------------------------------- foreign function
|
= note: `#[warn(unused_attributes)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: symbol names in extern blocks are not mangled
For more information about this error, try `rustc --explain E0557`.
warning: `Rust_testing` (bin "converted_hello") generated 1 warning
error: could not compile `Rust_testing` due to 2 previous errors; 1 warning emitted |
|
We should also stop emitting the |
It seems what |
It would not be valid C++, but in C main is allowed to have an implementation defined signature that returns void. So it's merely non-portable C. |
I filed issues for the two bugs here: |
Ah, I didn't realize that. Are there use cases for this that are in significant usage? |
c2rust
generated program using rustc
c2rust
generated program using rustc
c2rust
-generated program using rustc
Closing in favor of these more specific issues. |
Here's my C code:
Here's the rust code generated by c2rust:
I'm unable to compile the generated code using rustc.
When tried to compile it gives the following error message:
The text was updated successfully, but these errors were encountered: