informationsea / xlsxwriter-rs

Excel file writer for Rust
https://crates.io/crates/xlsxwriter
Apache License 2.0
265 stars 44 forks source link

fix build error on macOS #39

Closed eksea closed 1 year ago

eksea commented 1 year ago

hello, it occurs a compile error when i was trying to use the crate in my project. here's the error message

error[E0412]: cannot find type `c_char` in module `std::ffi`
   --> /Users/jack/.cargo/registry/src/github.com-1ecc6299db9ec823/xlsxwriter-0.5.0/src/worksheet/filter.rs:108:91
    |
108 |             value_string: c_string_helper.add_opt(self.value.to_str())? as *mut std::ffi::c_char,
    |                                                                                           ^^^^^^ not found in `std::ffi`
    |
help: consider importing one of these items
    |
1   | use crate::c_char;
    |
1   | use std::os::raw::c_char;
    |

error[E0412]: cannot find type `c_char` in module `std::ffi`
   --> /Users/jack/.cargo/registry/src/github.com-1ecc6299db9ec823/xlsxwriter-0.5.0/src/worksheet/filter.rs:271:70
    |
271 |                 .map(|x| Ok(cstring_helper.add(x)? as *mut std::ffi::c_char)),
    |                                                                      ^^^^^^ not found in `std::ffi`
    |
help: consider importing one of these items
    |
1   | use crate::c_char;
    |
1   | use std::os::raw::c_char;
    |

error[E0412]: cannot find type `c_char` in module `std::ffi`
   --> /Users/jack/.cargo/registry/src/github.com-1ecc6299db9ec823/xlsxwriter-0.5.0/src/worksheet/mod.rs:338:93
    |
338 |             author: workbook.register_option_str(self.author.as_deref())? as *mut std::ffi::c_char,
    |                                                                                             ^^^^^^ not found in `std::ffi`
    |
help: consider importing one of these items
    |
5   | use crate::c_char;
    |
5   | use std::os::raw::c_char;
    |

error[E0412]: cannot find type `c_char` in module `std::ffi`
   --> /Users/jack/.cargo/registry/src/github.com-1ecc6299db9ec823/xlsxwriter-0.5.0/src/worksheet/mod.rs:345:35
    |
345 |                 as *mut std::ffi::c_char,
    |                                   ^^^^^^ not found in `std::ffi`
    |
help: consider importing one of these items
    |
5   | use crate::c_char;
    |
5   | use std::os::raw::c_char;
    |

For more information about this error, try `rustc --explain E0412`.
error: could not compile `xlsxwriter` due to 4 previous errors
eksea commented 1 year ago

Today, i build my project on Windows, it also has the same build error.

informationsea commented 1 year ago

I could not reproduce this error on my environment including windows and macos. Which rust version and target are you using?

eksea commented 1 year ago

I could not reproduce this error on my environment including windows and macos. Which rust version and target are you using?

rust version is 1.62.1 on my Windows and 1.59.0 on my MacBook.

informationsea commented 1 year ago

Thank you. I found that std::ffi::c_char was introduced in latest Rust 1.64.0.