Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: Treat omitted ABI in extern block as "C". #944

Merged
merged 1 commit into from Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
}