Skip to content

Commit e211464

Browse files
committed
parser: Treat omitted ABI in extern block as "C".
As per https://doc.rust-lang.org/reference/items/external-blocks.html#abi Closes #709
1 parent 92f9d3b commit e211464

11 files changed

+23
-1
lines changed

src/bindgen/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ impl Parse {
600600
mod_cfg: Option<&Cfg>,
601601
item: &syn::ItemForeignMod,
602602
) {
603-
if !item.abi.is_c() {
603+
if !item.abi.is_c() && !item.abi.is_omitted() {
604604
info!("Skip {} - (extern block must be extern C).", crate_name);
605605
return;
606606
}

tests/expectations/extern.c

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ typedef struct {
1111
extern int32_t foo(void);
1212

1313
extern void bar(Normal a);
14+
15+
extern int32_t baz(void);

tests/expectations/extern.compat.c

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ extern int32_t foo(void);
1616

1717
extern void bar(Normal a);
1818

19+
extern int32_t baz(void);
20+
1921
#ifdef __cplusplus
2022
} // extern "C"
2123
#endif // __cplusplus

tests/expectations/extern.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ extern int32_t foo();
1515

1616
extern void bar(Normal a);
1717

18+
extern int32_t baz();
19+
1820
} // extern "C"

tests/expectations/extern.pyx

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ cdef extern from *:
1313
extern int32_t foo();
1414

1515
extern void bar(Normal a);
16+
17+
extern int32_t baz();

tests/expectations/extern_both.c

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ typedef struct Normal {
1111
extern int32_t foo(void);
1212

1313
extern void bar(struct Normal a);
14+
15+
extern int32_t baz(void);

tests/expectations/extern_both.compat.c

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ extern int32_t foo(void);
1616

1717
extern void bar(struct Normal a);
1818

19+
extern int32_t baz(void);
20+
1921
#ifdef __cplusplus
2022
} // extern "C"
2123
#endif // __cplusplus

tests/expectations/extern_tag.c

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ struct Normal {
1111
extern int32_t foo(void);
1212

1313
extern void bar(struct Normal a);
14+
15+
extern int32_t baz(void);

tests/expectations/extern_tag.compat.c

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ extern int32_t foo(void);
1616

1717
extern void bar(struct Normal a);
1818

19+
extern int32_t baz(void);
20+
1921
#ifdef __cplusplus
2022
} // extern "C"
2123
#endif // __cplusplus

tests/expectations/extern_tag.pyx

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ cdef extern from *:
1313
extern int32_t foo();
1414

1515
extern void bar(Normal a);
16+
17+
extern int32_t baz();

tests/rust/extern.rs

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ extern "C" {
99

1010
fn bar(a: Normal);
1111
}
12+
13+
extern {
14+
fn baz() -> i32;
15+
}

0 commit comments

Comments
 (0)