rust-lang / rust-lang/rust-bindgen
error[E0412]: cannot find type `_CharT` in this scope
Open
Nobody has claimed this yet.
A-C++
A-templates
I-bogus-codegen
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
This looks similar to #798, but I'm not sure if it is the same. I'm working on bindings for Octave and this comes up from the gcc headers related to std::string. https://github.com/ctaggart/octh/issues/8
Input C/C++ Header
template <typename, typename = int> class a;
template <typename _CharT> class b { _CharT c; };
template <typename _CharT, typename> class a : b<_CharT> { class B; };
template <typename _CharT, typename d> class a<_CharT, d>::B {
a<_CharT, d> e;
};
class octave_diary_stream : a<char> {};
Bindgen Invocation
#!/usr/bin/env bash
set -eu
clang-3.9 --std=c++11 -c __bindgen.ii
~/rust-bindgen/target/release/bindgen \
--output __bindgen.rs \
--enable-cxx-namespaces \
--whitelist-type octave.* \
--whitelist-function octave.* \
--use-core \
--raw-line "extern crate core;" \
__bindgen.ii \
-- -v -x c++ -std=c++11 \
2>/dev/null
rustc __bindgen.rs \
2>&1 \
| grep 'error\[E0412\]: cannot find type `_CharT` in this scope'
# time creduce ./bindgen-octh-8.sh __bindgen.ii
Actual Results
error[E0412]: cannot find type `_CharT` in this scope
Expected Results
No error. Either _CharT is defined or replaced.
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 running the provided bindgen-octh-8.sh workflow against the reduced C++ header and inspect the generated __bindgen.rs output. Compare the template and nested-class handling around the reported _CharT reference; done means the reproducer no longer emits E0412 and _CharT is defined or replaced as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100