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

failed in cargo build #3

Closed
yaoyaoio opened this issue Mar 7, 2023 · 1 comment · Fixed by #4
Closed

failed in cargo build #3

yaoyaoio opened this issue Mar 7, 2023 · 1 comment · Fixed by #4

Comments

@yaoyaoio
Copy link

yaoyaoio commented Mar 7, 2023

cargo build
error[E0308]: mismatched types
    --> src/types.rs:1538:45
     |
1538 |         let c_str = unsafe { CStr::from_ptr(&strs[off as usize] as *const u8 as *const i8) };
     |                              -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
     |                              |
     |                              arguments to this function are incorrect
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: associated function defined here

Hi, How to solve this problem?

@yaoyaoio yaoyaoio changed the title arguments to this function are incorrect failed in cargo build Mar 7, 2023
anakryiko added a commit that referenced this issue Mar 8, 2023
Seems like CStr::from_ptr is expecting a pointer to c_char, not i8 (as
you could get from documentation at [0]). So cast to c_char to solve the
problem.

  [0] https://doc.rust-lang.org/std/ffi/struct.CStr.html#impl-CStr

Fixes: #3
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
anakryiko added a commit that referenced this issue Mar 8, 2023
Seems like CStr::from_ptr is expecting a pointer to c_char, not i8 (as
you could get from documentation at [0]). So cast to c_char to solve the
problem.

  [0] https://doc.rust-lang.org/std/ffi/struct.CStr.html#impl-CStr

Fixes: #3
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
@anakryiko
Copy link
Owner

Please see if #4 fixes the issue. Thanks for reporting!

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

Successfully merging a pull request may close this issue.

2 participants