Skip to content

Simple struct with string doesn't compile #1597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AurelienFT opened this issue Jul 24, 2019 · 1 comment
Closed

Simple struct with string doesn't compile #1597

AurelienFT opened this issue Jul 24, 2019 · 1 comment

Comments

@AurelienFT
Copy link

Input C/C++ Header

#include <string>

struct SurfaceEntry
{
    std::string nodeId;
};

Bindgen Invocation

$ bindgen wrapper.hpp -- -x c++ > src/bindings.rs

After I compile with:

$ rustc src/bindings.rs

Actual Results

Rustc failed:

error[E0412]: cannot find type `_Value` in this scope
    --> src/bindings.rs:2572:33
     |
2572 |     pub static __gnu_cxx___min: _Value;
     |                                 ^^^^^^ not found in this scope

error[E0412]: cannot find type `_Value` in this scope
    --> src/bindings.rs:2576:33
     |
2576 |     pub static __gnu_cxx___max: _Value;
     |                                 ^^^^^^ not found in this scope

error[E0601]: `main` function not found in crate `bindings`
  |
  = note: consider adding a `main` function to `src/bindings.rs`

error[E0277]: `[u8; 44]` doesn't implement `std::fmt::Debug`
    --> src/bindings.rs:4208:5
     |
4208 |     pub _bitfield_1: __BindgenBitfieldUnit<[u8; 44usize], u8>,
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `[u8; 44]` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
     |
     = help: the trait `std::fmt::Debug` is not implemented for `[u8; 44]`
     = note: required because of the requirements on the impl of `std::fmt::Debug` for `__BindgenBitfieldUnit<[u8; 44], u8>`
     = note: required because of the requirements on the impl of `std::fmt::Debug` for `&__BindgenBitfieldUnit<[u8; 44], u8>`
     = note: required for the cast to the object type `dyn std::fmt::Debug`

error[E0277]: the trait bound `[u8; 44]: std::default::Default` is not satisfied
    --> src/bindings.rs:4427:13
     |
4427 |             Default::default();
     |             ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `[u8; 44]`
     |
     = help: the following implementations were found:
               <&[T] as std::default::Default>
               <&mut [T] as std::default::Default>
               <[T; 0] as std::default::Default>
               <[T; 10] as std::default::Default>
             and 31 others
     = note: required because of the requirements on the impl of `std::default::Default` for `__BindgenBitfieldUnit<[u8; 44], u8>`
     = note: required by `std::default::Default::default`

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0277, E0412, E0601.
For more information about an error, try `rustc --explain E0277`.

Expected Results

The rustc don't have errors.

The use case is very simple so I'm assuming I'm doing something wrong but I do not understand what.

@emilio
Copy link
Contributor

emilio commented Aug 31, 2019

This is kind of expected. STL is template-soup and bindgen doesn't generate every-possible-template ever. There's #738 about supporting these better. For now the best solution is making these opaque.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants