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