rust-lang / rust-lang/rust-bindgen

literal string definitons, their translation to charakter arrays and `*const c_char` compatibility

Open
#1,401 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

literal strings in C preprocessor definitions are translated to static character arrays by bindgen

e.g.

#define kOfxImageEffectPluginApi "OfxImageEffectPluginAPI"

becomes on my linux system:

pub const kOfxImageEffectPluginApi: &'static [u8; 24] = b"OfxImageEffectPluginAPI\x00"

the issue with this solution has to be seen in the choice of u8, because the affected C strings are very often used in places, where a *const c_char is expected, but c_char may be of type i8 on some systems and u8 on others.
this behavior enforces a lot of unpleasant and error prone further type casts.

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.

Research direction

No file or test is named in the issue. Start by locating bindgen's handling of C preprocessor string definitions and inspect the generated constant shown in the report; done means the generated string representation can be used where *const c_char is expected on systems with either c_char type.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.