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

cannot apply unary operator - to type u8 on arm64 #13

Open
matwey opened this issue Oct 20, 2023 · 3 comments
Open

cannot apply unary operator - to type u8 on arm64 #13

matwey opened this issue Oct 20, 2023 · 3 comments

Comments

@matwey
Copy link

matwey commented Oct 20, 2023

When building 0.195.1 on aarch64 architecture the following issue happens:

[  209s] error[E0600]: cannot apply unary operator `-` to type `u8`
[  209s]     --> flux/src/cffi.rs:1152:35
[  209s]      |
[  209s] 1152 |         let v: Vec<c_char> = vec![-61, 0];
[  209s]      |                                   ^^^ cannot apply unary operator `-`
[  209s]      |
[  209s]      = note: unsigned values cannot be negated
@lmangani
Copy link
Collaborator

Interesting. I'm not 100% sure but did some quick research and it seems only valid signed 8-bit characters should be used in Vec<c_char>. I guess x86, the code might be lenient and allow negative values for u8, but on ARM64 it seems using signed values might be required. We could change the code to use valid signed 8-bit characters by specifying the type as i8

let v: Vec<c_char> = vec![-61i8, 0i8];

Would you be willing to try and confirm if this approach works?

@matwey
Copy link
Author

matwey commented Oct 20, 2023

I cannot check right now, but I know for sure that char type in C has different signedness on different platforms.

@andreas-schwab
Copy link

If you want to process an UTF-8 string you should use unsigned char, not char.

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