rust-lang / rust-lang/rust-bindgen

C globals with initializers turned into Rust constants

Open
#2,465 1 comment 0 reactions 1 assignee View on GitHub

@pvdrz is already working on this.

Since Mar 23, 2023.

I-bogus-codegen
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Input C/C++ Header
int foo;
int withinit = 123;
Bindgen Invocation

bindgen test.h -- -std=c99

Actual Results
/* automatically generated by rust-bindgen 0.64.0 */

extern "C" {
    pub static mut foo: ::std::os::raw::c_int;
}
pub const withinit: ::std::os::raw::c_int = 123;
Expected Results

It should give static in both cases. The C global is not constant just because it has an initializer.

Happens on 0.64.0 and on main(a1216813fa9b4a856f84c086754d9f2c876be794)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.