Skip to content

Instantly share code, notes, and snippets.

@paulrouget
Created January 18, 2019 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulrouget/eb6297fce179186e0ef544a243c48505 to your computer and use it in GitHub Desktop.
Save paulrouget/eb6297fce179186e0ef544a243c48505 to your computer and use it in GitHub Desktop.
Bindgen generates this struct:
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct pthread_mutex_t {
pub value: ::std::os::raw::c_int,
}
That's valid and it works, but everytime I want to use
this `pthread_mutex_t` type with `libc::pthread_mutex_lock()`
I have to cast it into `libc::pthread_mutex_t`:
let libc_mutex_ptr = &mut bindgen_mutex as *mut _ as *mut libc::pthread_mutex_t;
This kind of cast happens all over my code. Is there a way to either:
1) make it so bindgen re-use libc::pthread_mutex_t instead of creating its own,
2) or, have an elegant way to cast from bindgen mutex to libc mutex?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment