Skip to content

Commit 6ffd7bc

Browse files
authored
Merge pull request #23 from Sympatron/short-enums
Make sure cc and bindgen use the same size for enums
2 parents ac83e92 + 7e57976 commit 6ffd7bc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

libosdp-sys/build.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,20 @@ fn main() -> Result<()> {
162162
.file("vendor/src/osdp_pcap.c");
163163
}
164164

165+
let short_enums = build.get_compiler().is_like_gnu() || build.get_compiler().is_like_clang();
166+
if short_enums {
167+
build.flag("-fshort-enums");
168+
}
165169
build.compile("libosdp.a");
166170

167171
/* generate bindings */
168172

169-
let args = vec![format!("-I{}", &out_dir)];
173+
let mut args = vec![format!("-I{}", &out_dir)];
174+
if short_enums {
175+
args.push("-fshort-enums".to_owned());
176+
} else {
177+
args.push("-fno-short-enums".to_owned());
178+
}
170179
let bindings = bindgen::Builder::default()
171180
.use_core()
172181
.header("vendor/include/osdp.h")

0 commit comments

Comments
 (0)