cfg.rs 955 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #[cfg(all(unix, x11))]
  2. #[repr(u32)]
  3. enum FooType {
  4. A,
  5. B,
  6. C,
  7. }
  8. #[cfg(all(unix, x11))]
  9. #[repr(C)]
  10. struct FooHandle {
  11. ty: FooType,
  12. x: i32,
  13. y: f32,
  14. }
  15. #[cfg(any(windows, target_pointer_width="32"))]
  16. #[repr(u32)]
  17. enum BarType {
  18. A,
  19. B,
  20. C,
  21. }
  22. #[repr(u8)]
  23. pub enum C {
  24. C1,
  25. C2,
  26. #[cfg(windows)]
  27. C3,
  28. #[cfg(unix)]
  29. C5 { int: i32 },
  30. }
  31. #[cfg(any(windows, target_pointer_width="32"))]
  32. #[repr(C)]
  33. struct BarHandle {
  34. ty: BarType,
  35. x: i32,
  36. y: f32,
  37. }
  38. // FIXME(#634): Support deriving methods for structs with conditional fields.
  39. /// cbindgen:derive-eq=false
  40. /// cbindgen:derive-neq=false
  41. #[repr(C)]
  42. struct ConditionalField {
  43. #[cfg(x11)]
  44. field: i32,
  45. }
  46. #[cfg(all(unix, x11))]
  47. #[no_mangle]
  48. pub extern "C" fn root(a: FooHandle, c: C)
  49. { }
  50. #[cfg(any(windows, target_pointer_width="32"))]
  51. #[no_mangle]
  52. pub extern "C" fn root(a: BarHandle, c: C)
  53. { }
  54. #[no_mangle]
  55. pub extern "C" fn cond(a: ConditionalField)
  56. { }