Skip to content

Commit

Permalink
Fix c_char type error (i8 vs u8) when building on linux arm64
Browse files Browse the repository at this point in the history
The error was following:

```
error[E0308]: mismatched types
  --> /home/[redacted]/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/elephantry-3.0.0/src/connection.rs:41:50
   |
41 |             connection.set_notice_processor(Some(notice_processor), std::ptr::null_mut());
   |                                             ---- ^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
   |                                             |
   |                                             arguments to this enum variant are incorrect
   |
   = note: expected fn pointer `unsafe extern "C" fn(_, *const u8)`
                 found fn item `extern "C" fn(_, *const i8) {notice_processor}`
```

Relevant links:
- rust-lang/rust#60226
- https://github.com/sportsball-ai/blackmagic-raw-rs/pull/3/files
  • Loading branch information
lks128 committed Feb 14, 2023
1 parent b427a9b commit 4f0fdbf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct Connection {
pub(crate) connection: std::sync::Arc<std::sync::Mutex<libpq::Connection>>,
}

extern "C" fn notice_processor(_arg: *mut std::ffi::c_void, message: *const i8) {
extern "C" fn notice_processor(_arg: *mut std::ffi::c_void, message: *const std::ffi::c_char) {
let message = unsafe { std::ffi::CStr::from_ptr(message) };

log::info!("{}", message.to_str().unwrap().trim());
Expand Down

0 comments on commit 4f0fdbf

Please sign in to comment.