Skip to content

Commit a09dcac

Browse files
LunarEclipse363oSoMoN
authored andcommitted
Fix compilation for 32-bit targets
1 parent 98bf765 commit a09dcac

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/cmp.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,22 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
9090
"M" => 1_048_576,
9191
"GB" => 1_000_000_000,
9292
"G" => 1_073_741_824,
93-
"TB" => 1_000_000_000_000,
94-
"T" => 1_099_511_627_776,
95-
"PB" => 1_000_000_000_000_000,
96-
"P" => 1_125_899_906_842_624,
97-
"EB" => 1_000_000_000_000_000_000,
98-
"E" => 1_152_921_504_606_846_976,
93+
// This only generates a warning when compiling for target_pointer_width < 64
94+
#[allow(unused_variables)]
95+
suffix @ ("TB" | "T" | "PB" | "P" | "EB" | "E") => {
96+
#[cfg(target_pointer_width = "64")]
97+
match suffix {
98+
"TB" => 1_000_000_000_000,
99+
"T" => 1_099_511_627_776,
100+
"PB" => 1_000_000_000_000_000,
101+
"P" => 1_125_899_906_842_624,
102+
"EB" => 1_000_000_000_000_000_000,
103+
"E" => 1_152_921_504_606_846_976,
104+
_ => unreachable!(),
105+
}
106+
#[cfg(not(target_pointer_width = "64"))]
107+
usize::MAX
108+
}
99109
"ZB" => usize::MAX, // 1_000_000_000_000_000_000_000,
100110
"Z" => usize::MAX, // 1_180_591_620_717_411_303_424,
101111
"YB" => usize::MAX, // 1_000_000_000_000_000_000_000_000,

0 commit comments

Comments
 (0)