Skip to content

Commit

Permalink
Handle incomplete external array constants
Browse files Browse the repository at this point in the history
This adds a new special case for constants like:
```c
extern const char some_static_string[];
```
so `bindgen` emits a `static` instead of a `static mut` for them.
  • Loading branch information
pvdrz authored and emilio committed Oct 16, 2022
1 parent 626797b commit 17dd093
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bindgen-tests/tests/expectations/tests/var-tracing.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion bindgen/ir/var.rs
Expand Up @@ -285,7 +285,8 @@ impl ClangSubItemParser for Var {
// TODO(emilio): do we have to special-case constant arrays in
// some other places?
let is_const = ty.is_const() ||
(ty.kind() == CXType_ConstantArray &&
([CXType_ConstantArray, CXType_IncompleteArray]
.contains(&ty.kind()) &&
ty.elem_type()
.map_or(false, |element| element.is_const()));

Expand Down

0 comments on commit 17dd093

Please sign in to comment.