diff --git a/src/bindgen/utilities.rs b/src/bindgen/utilities.rs index bea1d99a4..ff375457c 100644 --- a/src/bindgen/utilities.rs +++ b/src/bindgen/utilities.rs @@ -263,7 +263,7 @@ impl SynAbiHelpers for Option { fn is_c(&self) -> bool { if let Some(ref abi) = *self { if let Some(ref lit_string) = abi.name { - return lit_string.value() == "C"; + return matches!(lit_string.value().as_str(), "C" | "C-unwind"); } } false @@ -280,7 +280,7 @@ impl SynAbiHelpers for Option { impl SynAbiHelpers for syn::Abi { fn is_c(&self) -> bool { if let Some(ref lit_string) = self.name { - lit_string.value() == "C" + matches!(lit_string.value().as_str(), "C" | "C-unwind") } else { false } diff --git a/tests/expectations/abi_string.c b/tests/expectations/abi_string.c new file mode 100644 index 000000000..6a7a59047 --- /dev/null +++ b/tests/expectations/abi_string.c @@ -0,0 +1,8 @@ +#include +#include +#include +#include + +void c(void); + +void c_unwind(void); diff --git a/tests/expectations/abi_string.compat.c b/tests/expectations/abi_string.compat.c new file mode 100644 index 000000000..0fad55a07 --- /dev/null +++ b/tests/expectations/abi_string.compat.c @@ -0,0 +1,16 @@ +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void c(void); + +void c_unwind(void); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tests/expectations/abi_string.cpp b/tests/expectations/abi_string.cpp new file mode 100644 index 000000000..0e86af9af --- /dev/null +++ b/tests/expectations/abi_string.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include +#include + +extern "C" { + +void c(); + +void c_unwind(); + +} // extern "C" diff --git a/tests/expectations/abi_string.pyx b/tests/expectations/abi_string.pyx new file mode 100644 index 000000000..59a83d3bc --- /dev/null +++ b/tests/expectations/abi_string.pyx @@ -0,0 +1,11 @@ +from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t +from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t +cdef extern from *: + ctypedef bint bool + ctypedef struct va_list + +cdef extern from *: + + void c(); + + void c_unwind(); diff --git a/tests/rust/abi_string.rs b/tests/rust/abi_string.rs new file mode 100644 index 000000000..f685532e2 --- /dev/null +++ b/tests/rust/abi_string.rs @@ -0,0 +1,5 @@ +#[no_mangle] +pub extern "C" fn c() {} + +#[no_mangle] +pub extern "C-unwind" fn c_unwind() {}