pd-rs / crankstart

A barely functional, wildly incomplete and basically undocumented Rust crate whose aim is to let you write Games for the Playdate handheld gaming system in Rust.
MIT License
235 stars 24 forks source link

Cargo fails to build crankstart (and examples) #11

Closed JaapRood closed 2 years ago

JaapRood commented 2 years ago

Hey there, so awesome to see people working on this! I'm quite obviously really missing something (all production Rust I've written so far doesn't deal with FFIs or no_std), but I can't seem to get a project to build due to crankstart compile errors. Going back to basics I tried to run the example as instructed in the README.

crank run --release --example hello_world

Yields 18 cases of expectedi8, foundu8` (see below), all seemingly around pointer stuff, the same thing I'm getting for trying to build / run a standalone project as well, all Here's a sample.

 error[E0308]: mismatched types
  --> src/file.rs:19:50
   |
19 |         let err_string = unsafe { CStr::from_ptr(err_result) };
   |                                                  ^^^^^^^^^^ expected `i8`, found `u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  --> src/file.rs:35:35
   |
35 |         let path = CStr::from_ptr(filename).to_string_lossy().into_owned();
   |                                   ^^^^^^^^ expected `i8`, found `u8`
   |
   = note: expected raw pointer `*const i8`
              found raw pointer `*const u8`

error[E0308]: mismatched types
  --> src/file.rs:58:13
   |
58 |             c_path.as_ptr(),
   |             ^^^^^^^^^^^^^^^ expected `u8`, found `i8`
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`

error[E0308]: mismatched types
  --> src/file.rs:69:54
   |
69 |         let result = pd_func_caller!((*self.0).stat, c_path.as_ptr(), &mut file_stat)?;
   |                                                      ^^^^^^^^^^^^^^^ expected `u8`, found `i8`
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`

Running toolchain:

nightly-aarch64-apple-darwin (default)
rustc 1.61.0-nightly (461e80780 2022-03-16)

My gut says I'm probably missing something very basic Rust idea here, but I'm kind of stuck on figuring out what that is. Even the vaguest suggestion might help me out :)

rtsuk commented 2 years ago

This might be related to being on an Apple Silicon host. I will give that a quick test.

rtsuk commented 2 years ago

Ah, you've gotten a newer version of a crate that isn't as compatible as one might hope. Let me see what I can do to fix it.

rtsuk commented 2 years ago

Please give it a try now.

JaapRood commented 2 years ago

And we're up and running, thanks so much for the super speedy reply and fix! So it was cstr_core that broke and I got a newer version than what was locked for you locally?

rtsuk commented 2 years ago

Indeed.