Skip to content

Commit

Permalink
parser: Treat omitted ABI in extern block as "C".
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Apr 15, 2024
1 parent 92f9d3b commit e211464
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bindgen/parser.rs
Expand Up @@ -600,7 +600,7 @@ impl Parse {
mod_cfg: Option<&Cfg>,
item: &syn::ItemForeignMod,
) {
if !item.abi.is_c() {
if !item.abi.is_c() && !item.abi.is_omitted() {
info!("Skip {} - (extern block must be extern C).", crate_name);
return;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/expectations/extern.c
Expand Up @@ -11,3 +11,5 @@ typedef struct {
extern int32_t foo(void);

extern void bar(Normal a);

extern int32_t baz(void);
2 changes: 2 additions & 0 deletions tests/expectations/extern.compat.c
Expand Up @@ -16,6 +16,8 @@ extern int32_t foo(void);

extern void bar(Normal a);

extern int32_t baz(void);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
2 changes: 2 additions & 0 deletions tests/expectations/extern.cpp
Expand Up @@ -15,4 +15,6 @@ extern int32_t foo();

extern void bar(Normal a);

extern int32_t baz();

} // extern "C"
2 changes: 2 additions & 0 deletions tests/expectations/extern.pyx
Expand Up @@ -13,3 +13,5 @@ cdef extern from *:
extern int32_t foo();

extern void bar(Normal a);

extern int32_t baz();
2 changes: 2 additions & 0 deletions tests/expectations/extern_both.c
Expand Up @@ -11,3 +11,5 @@ typedef struct Normal {
extern int32_t foo(void);

extern void bar(struct Normal a);

extern int32_t baz(void);
2 changes: 2 additions & 0 deletions tests/expectations/extern_both.compat.c
Expand Up @@ -16,6 +16,8 @@ extern int32_t foo(void);

extern void bar(struct Normal a);

extern int32_t baz(void);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
2 changes: 2 additions & 0 deletions tests/expectations/extern_tag.c
Expand Up @@ -11,3 +11,5 @@ struct Normal {
extern int32_t foo(void);

extern void bar(struct Normal a);

extern int32_t baz(void);
2 changes: 2 additions & 0 deletions tests/expectations/extern_tag.compat.c
Expand Up @@ -16,6 +16,8 @@ extern int32_t foo(void);

extern void bar(struct Normal a);

extern int32_t baz(void);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
2 changes: 2 additions & 0 deletions tests/expectations/extern_tag.pyx
Expand Up @@ -13,3 +13,5 @@ cdef extern from *:
extern int32_t foo();

extern void bar(Normal a);

extern int32_t baz();
4 changes: 4 additions & 0 deletions tests/rust/extern.rs
Expand Up @@ -9,3 +9,7 @@ extern "C" {

fn bar(a: Normal);
}

extern {
fn baz() -> i32;
}

0 comments on commit e211464

Please sign in to comment.