diff --git a/src/header/monetary/cbindgen.toml b/src/header/monetary/cbindgen.toml index 59294e84c5..003cbd5026 100644 --- a/src/header/monetary/cbindgen.toml +++ b/src/header/monetary/cbindgen.toml @@ -15,6 +15,7 @@ language = "C" style = "tag" no_includes = true cpp_compat = true +usize_is_size_t = true [enum] prefix_with_name = true diff --git a/src/header/monetary/strfmon.rs b/src/header/monetary/strfmon.rs index ac436d4e9a..c0f380604e 100644 --- a/src/header/monetary/strfmon.rs +++ b/src/header/monetary/strfmon.rs @@ -1,4 +1,4 @@ -use crate::platform::types::c_char; +use crate::platform::types::{c_char, size_t, ssize_t}; use super::{DEFAULT_MONETARY, FormatFlags, LocaleMonetaryInfo, apply_grouping}; use alloc::string::{String, ToString}; @@ -17,10 +17,10 @@ use libm::{fabs, pow, round, trunc}; #[unsafe(no_mangle)] pub unsafe extern "C" fn strfmon( s: *mut c_char, // Output buffer - maxsize: usize, // Maximum size of the buffer + maxsize: size_t, // Maximum size of the buffer format: *const c_char, // Format string mut args: ... // Variadic arguments for monetary values -) -> isize { +) -> ssize_t { // Validate input pointers and buffer size if s.is_null() || format.is_null() || maxsize == 0 { return -1; // Invalid input @@ -151,7 +151,7 @@ pub unsafe extern "C" fn strfmon( return -1; // Buffer overflow } buffer[pos] = 0; // Null-terminate the buffer - pos as isize // Return the number of characters written + pos as ssize_t // Return the number of characters written } /// Formats a monetary value into the given `buffer` using locale-specific rules