From 7e57976f21f2fcd530c8ec0c71e2e3b326ef565b Mon Sep 17 00:00:00 2001 From: Sympatron GmbH <35803463+Sympatron@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:28:01 +0100 Subject: [PATCH] Make sure cc and bindgen use the same size for enums --- libosdp-sys/build.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libosdp-sys/build.rs b/libosdp-sys/build.rs index 6946d9a..e94ae86 100644 --- a/libosdp-sys/build.rs +++ b/libosdp-sys/build.rs @@ -162,11 +162,20 @@ fn main() -> Result<()> { .file("vendor/src/osdp_pcap.c"); } + let short_enums = build.get_compiler().is_like_gnu() || build.get_compiler().is_like_clang(); + if short_enums { + build.flag("-fshort-enums"); + } build.compile("libosdp.a"); /* generate bindings */ - let args = vec![format!("-I{}", &out_dir)]; + let mut args = vec![format!("-I{}", &out_dir)]; + if short_enums { + args.push("-fshort-enums".to_owned()); + } else { + args.push("-fno-short-enums".to_owned()); + } let bindings = bindgen::Builder::default() .use_core() .header("vendor/include/osdp.h")