Skip to content

Commit 17dd093

Browse files
pvdrzemilio
authored andcommitted
Handle incomplete external array constants
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.
1 parent 626797b commit 17dd093

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

bindgen-tests/tests/expectations/tests/var-tracing.rs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen/ir/var.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ impl ClangSubItemParser for Var {
285285
// TODO(emilio): do we have to special-case constant arrays in
286286
// some other places?
287287
let is_const = ty.is_const() ||
288-
(ty.kind() == CXType_ConstantArray &&
288+
([CXType_ConstantArray, CXType_IncompleteArray]
289+
.contains(&ty.kind()) &&
289290
ty.elem_type()
290291
.map_or(false, |element| element.is_const()));
291292

0 commit comments

Comments
 (0)