Skip to content

Commit 4179f25

Browse files
Use c_char instead of i8 for cross-platform compatibility
c_char is u8 on ARM64 Linux but i8 on x86, so use the portable c_char type from std::ffi for argv handling. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 912b156 commit 4179f25

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Roc platform host implementation for basic-cli using the new RocOps-based ABI.
22
3-
use std::ffi::c_void;
3+
use std::ffi::{c_char, c_void};
44
use std::fs;
55
use std::io::{self, BufRead, Write};
66
use std::sync::atomic::{AtomicBool, Ordering};
@@ -960,7 +960,7 @@ static HOSTED_FNS: [HostedFn; 27] = [
960960
///
961961
/// Uses argc/argv directly instead of std::env::args() because when built
962962
/// as a static library, the Rust runtime isn't properly initialized.
963-
fn build_args_list(argc: i32, argv: *const *const i8, roc_ops: &RocOps) -> RocList<RocStr> {
963+
fn build_args_list(argc: i32, argv: *const *const c_char, roc_ops: &RocOps) -> RocList<RocStr> {
964964
if argc <= 0 || argv.is_null() {
965965
return RocList::empty();
966966
}
@@ -985,12 +985,12 @@ fn build_args_list(argc: i32, argv: *const *const i8, roc_ops: &RocOps) -> RocLi
985985
/// C-compatible main entry point for the Roc program.
986986
/// This is exported so the linker can find it.
987987
#[no_mangle]
988-
pub extern "C" fn main(argc: i32, argv: *const *const i8) -> i32 {
988+
pub extern "C" fn main(argc: i32, argv: *const *const c_char) -> i32 {
989989
rust_main(argc, argv)
990990
}
991991

992992
/// Main entry point for the Roc program.
993-
pub fn rust_main(argc: i32, argv: *const *const i8) -> i32 {
993+
pub fn rust_main(argc: i32, argv: *const *const c_char) -> i32 {
994994
// Create the RocOps struct with all callbacks
995995
// We Box it to ensure stable memory address
996996
let roc_ops = Box::new(RocOps {

0 commit comments

Comments
 (0)