Guest User

Untitled

a guest
Jan 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. Bindgen generates this struct:
  2.  
  3. #[repr(C)]
  4. #[derive(Debug, Copy, Clone)]
  5. pub struct pthread_mutex_t {
  6. pub value: ::std::os::raw::c_int,
  7. }
  8.  
  9. That's valid and it works, but everytime I want to use
  10. this `pthread_mutex_t` type with `libc::pthread_mutex_lock()`
  11. I have to cast it into `libc::pthread_mutex_t`:
  12.  
  13. let libc_mutex_ptr = &mut bindgen_mutex as *mut _ as *mut libc::pthread_mutex_t;
  14.  
  15. This kind of cast happens all over my code. Is there a way to either:
  16.  
  17. 1) make it so bindgen re-use libc::pthread_mutex_t instead of creating its own,
  18. 2) or, have an elegant way to cast from bindgen mutex to libc mutex?
Add Comment
Please, Sign In to add comment