rust-lang / rust-lang/rust-bindgen
wrap_static_fns not generating extern.c when -x c++
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Calling option wrap-static-fns with -x c++ to force C++ mode (this also happens when simply calling bindgen on a .hpp file) (https://rust-lang.github.io/rust-bindgen/cpp.html) fails to create extern.cpp.
Considering this simple test.h file:
static void testing();
Calling bindgen with -x c++ to force C++ mode:
❯ bindgen test.h --wrap-static-fns -- -x c++
/* automatically generated by rust-bindgen 0.71.1 */
unsafe extern "C" {
#[link_name = "\u{1}_ZL7testingv"]
pub fn testing();
}
Doesn't generate extern.c at the default path (/tmp/bindgen on unix systems):
❯ cat /tmp/bindgen/extern.cpp
cat: /tmp/bindgen/extern.cpp: No such file or directory
Here's the default behavior without C++ mode (or .hpp):
❯ bindgen test.h --wrap-static-fns
/* automatically generated by rust-bindgen 0.71.1 */
unsafe extern "C" {
#[link_name = "testing__extern"]
pub fn testing();
}
Which does generate the static wrapper:
❯ cat /tmp/bindgen/extern.c
#include "test.h"
// Static wrappers
void testing__extern(void) { testing(); }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the bindgen CLI case with --wrap-static-fns and the -- -x c++ arguments, comparing it with the C-mode invocation. Trace the wrapper-generation path for the output filename and language mode; done means the C++ case generates /tmp/bindgen/extern.cpp containing the static wrapper.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100