|
Here you go. It didn't like my stdio.h. Apparently enums and unions aren't supported, but: extern int printf(char *, ...);
int main(int argc, char argv[]) {
printf("Hello, world!\n");
return 0;
}
Was turned into: extern {
fn printf(arg1 : *mut u8, ...) -> i32;
}
#[no_mangle]
pub unsafe fn main(mut argc : i32, mut argv : *mut u8) -> i32 {
printf(b"Hello, world!\n\0".as_ptr() as (*mut u8));
0i32
}
edit: Also worth noting, it removes all comments. I believe this to be a limitation of language-c [1][1] https://hackage.haskell.org/package/language-c |
From the description of how it translates a FOR loop, it does so by compiling it down to the primitive operations and tests. A Rust FOR loop does not emerge. That needs idiom recognition for the common cases including, at least, "for (i=0; i<n; i++) {...}".
This is a big job, but it's good someone started on it.