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

Using Rust to convert simple RosettaCode C-lang tasks #152

Open
abhi18av opened this issue Jun 11, 2017 · 3 comments
Open

Using Rust to convert simple RosettaCode C-lang tasks #152

abhi18av opened this issue Jun 11, 2017 · 3 comments

Comments

@abhi18av
Copy link

Hi again @jameysharp

Have you thought about using Corrode on small-ish C code?

I was experimenting with the C language tasks from RosettaCode but the errors I keep running into are sort of recurrent.

Let's take this for example

a+b-1.c

// Standard input-output streams
#include <stdio.h>
int main()
{
   int a, b;
   scanf("%d%d", &a, &b);
   printf("%d\n", a + b);
   return 0;
}

After running corrode I get two files

a+b-1.rs
a+b-1.o

Only the first one is saved.

I rename it as per rust conventions, so the compiler doesn't complain.

a_plus_b_1.rs

And when I try to compile it with rustc , I run into the following error

❯ rustc a_plus_b_1.rs
error[E0446]: private type `__sFILEX` in public interface
  --> a_plus_b_1.rs:37:5
   |
37 |     pub _extra : *mut __sFILEX,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type

error: aborting due to previous error


Then I remove/comment/modify the line 37 and the errors are related to usage of variable, which are to be read through stdin

❯ rustc a_plus_b_1.rs
error[E0381]: use of possibly uninitialized variable: `a`
  --> a_plus_b_1.rs:85:14
   |
85 |         &mut a as (*mut i32),
   |              ^ use of possibly uninitialized `a`

error[E0381]: use of possibly uninitialized variable: `b`
  --> a_plus_b_1.rs:86:14
   |
86 |         &mut b as (*mut i32)
   |              ^ use of possibly uninitialized `b`

error[E0381]: use of possibly uninitialized variable: `a`
  --> a_plus_b_1.rs:88:34
   |
88 |     printf((*b"%d\n\0").as_ptr(),a + b);
   |                                  ^ use of possibly uninitialized `a`

error[E0381]: use of possibly uninitialized variable: `b`
  --> a_plus_b_1.rs:88:38
   |
88 |     printf((*b"%d\n\0").as_ptr(),a + b);
   |                                      ^ use of possibly uninitialized `b`

error: aborting due to 4 previous errors
@abhi18av
Copy link
Author

The specific problems that I outlined here might not be that important, I can understand, but the point is RosettaCode could essentially prove to be a great resource for iterating on Corrode. Here's a repository using which you can isolate all the tasks done in C

https://github.com/acmeism/RosettaCodeData

@HopperMCS
Copy link

Is @jameysharp still alive?

@FSMaxB
Copy link

FSMaxB commented Jul 22, 2017

At least he was still alive 11 hours ago!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants