Skip to content

Use libc::c_char instead of i8 for char pointer casts#3

Open
jonathanrainer wants to merge 1 commit into0k:mainfrom
jonathanrainer:fix/aarch64-char-signedness
Open

Use libc::c_char instead of i8 for char pointer casts#3
jonathanrainer wants to merge 1 commit into0k:mainfrom
jonathanrainer:fix/aarch64-char-signedness

Conversation

@jonathanrainer
Copy link

On ARM64 Linux, C char is unsigned (u8), so the fyaml-sys bindings emit *const u8 for const char * parameters. However on x86 the C char is signed so an i8 is used instead. This is fine, but it means fyaml fails to compile on aarch64-unknown-linux-musl.

This is fixed by replacing all as *const i8 with as *const libc::c_char (= i8 on x86_64, u8 on aarch64) so the casts match the platform-appropriate type produced by bindgen, enabling builds on both architectures.

On ARM64 Linux, C `char` is unsigned (u8), so the fyaml-sys bindings
emit `*const u8` for `const char *` parameters. The hardcoded
`as *const i8` casts fail to compile on aarch64-unknown-linux-musl.

Replace all `as *const i8` with `as *const libc::c_char` (= i8 on
x86_64, u8 on aarch64) so the casts match the platform-appropriate type
produced by bindgen, enabling builds on both architectures.
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 this pull request may close these issues.

1 participant