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

Use c_char instead of i8 to compile on platforms where c_char = u8 #6572

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

itsjunetime
Copy link
Contributor

Which issue does this PR close?

Closes #6571

Rationale for this change

c_char is what is actually required for these APIs, so we should uniformly use it where required.

What changes are included in this PR?

Switches a bunch of i8s to c_chars

Are there any user-facing changes?

No

@github-actions github-actions bot added the arrow Changes to the arrow crate label Oct 16, 2024
@alamb
Copy link
Contributor

alamb commented Oct 16, 2024

Fascinating -- it appears 1.82 rust is scheduled to release tomorrow https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1820-2024-10-17

Maybe this is some sort of foreshadowing of what is to come

@@ -165,7 +165,7 @@ pub fn read_gzip_json(version: &str, path: &str) -> ArrowJson {

/// C Data Integration entrypoint to export the schema from a JSON file
fn cdata_integration_export_schema_from_json(
c_json_name: *const i8,
c_json_name: *const c_char,
out: *mut FFI_ArrowSchema,
) -> Result<()> {
let json_name = unsafe { CStr::from_ptr(c_json_name) };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is strange to me that the signature in std::ffi is ptr: *const i8, not *const c_char 🤔

https://doc.rust-lang.org/std/ffi/struct.CStr.html#method.from_ptr

Screenshot 2024-10-16 at 3 20 24 PM

Maybe it changed in 1.82 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it does seem to say *const i8 in the signature, but if you click through to the source, it shows ptr: *const c_char. I don't know what's up with that, it feels like a docs.rs bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, if you cd ~/.rustup/toolchains/stable-*/lib/rustlib/src/rust/library/core && RUSTC_BOOTSTRAP=1 cargo +stable doc --open, it shows ptr: *const c_char for this fn, which is correct. I'm going to try to figure out if someone else has reported this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @itsjunetime -- this makes sense to me

the CI failure https://github.com/apache/arrow-rs/actions/runs/11370034366/job/31636443148?pr=6572 on this PR is unrelated -- see #6568

@alamb
Copy link
Contributor

alamb commented Oct 17, 2024

CI Integration failure is tracked with #6577

This PR basically uses a different typedef, so I don't think it is a breaking change

Thus 🚀

@alamb alamb merged commit 9d06019 into apache:master Oct 17, 2024
12 of 13 checks passed
@alamb
Copy link
Contributor

alamb commented Oct 17, 2024

Thanks again @itsjunetime and @mbrobbel

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

Successfully merging this pull request may close these issues.

Compilation fail where c_char = u8
3 participants