Skip to content

Panic at TranslationUnit::parse #249

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
azerupi opened this issue Nov 13, 2016 · 6 comments
Closed

Panic at TranslationUnit::parse #249

azerupi opened this issue Nov 13, 2016 · 6 comments

Comments

@azerupi
Copy link

azerupi commented Nov 13, 2016

I tried to run bindgen on the openfx header files but I got a panic:

$ bindgen include/*.h                           
thread 'main' panicked at 'TranslationUnit::parse', ../src/libcore/option.rs:705
stack backtrace:
   1:     0x5589ab76be4f - std::sys::backtrace::tracing::imp::write::h6f1d53a70916b90d
   2:     0x5589ab77112d - std::panicking::default_hook::{{closure}}::h137e876f7d3b5850
   3:     0x5589ab77004a - std::panicking::default_hook::h0ac3811ec7cee78c
   4:     0x5589ab7705e8 - std::panicking::rust_panic_with_hook::hc303199e04562edf
   5:     0x5589ab770482 - std::panicking::begin_panic::h6ed03353807cf54d
   6:     0x5589ab7703c0 - std::panicking::begin_panic_fmt::hc321cece241bb2f5
   7:     0x5589ab770341 - rust_begin_unwind
   8:     0x5589ab7a7c8f - core::panicking::panic_fmt::h27224b181f9f037f
   9:     0x5589ab7a7d05 - core::option::expect_failed::h8606bc228cd3f504
  10:     0x5589ab4b737d - bindgen::ir::context::BindgenContext::new::hbb87c6d36471e05f
  11:     0x5589ab4ca0b0 - bindgen::Bindings::generate::h874f52036a1239e0
  12:     0x5589ab4c9d94 - bindgen::Builder::generate::hd73069614a30fa2a
  13:     0x5589ab432210 - bindgen::main::hace8f155f8b5cece
  14:     0x5589ab778bf6 - __rust_maybe_catch_panic
  15:     0x5589ab76f8c1 - std::rt::lang_start::h538f8960e7644c80
  16:     0x7f0bc867a290 - __libc_start_main
  17:     0x5589ab415319 - _start
  18:                0x0 - <unknown>

EDIT: I tried to run bindgen on every file individually, but I can't reproduce it that way...

@emilio
Copy link
Contributor

emilio commented Nov 13, 2016

Yes, bindgen right now doesn't support throwing multiple files at it directly. This in this case is somewhat silly because we can't sort the files for you, and files have dependencies between them.

The way to do it is either creating a master header file with the appropriate includes:

// all.h
#include "include/ofxCore.h"
// (and so on...)

Or using the -include clang flag in the appropriate order.

$ ./bindgen include/ofxCore.h -- -include "ofxFoo.h" -include "ofxBar.h" ...

I guess we can try to enhance the use, or at least the error message though, so leaving it open...

@azerupi
Copy link
Author

azerupi commented Nov 13, 2016

Oh right, my bad.. it does sound silly now that you say it.

I wonder, would it be possible for bindgen to create that "master file" including all the headers itself? Does order really matter if you include them all anyway? It could even be a temporary file so that it doesn't leave any artifacts

A better error message would be great! :)

@emilio
Copy link
Contributor

emilio commented Nov 14, 2016

Hmm... I don't think it's possible for bindgen to make the "master header" in the general case. There are definitely dependencies between headers. Usually not many in public APIs, but still existing.

@azerupi
Copy link
Author

azerupi commented Nov 14, 2016

There are definitely dependencies between headers.

It's been a long time since I have done any C / C++ but, assuming the headers have header guards preventing double inclusion, what other problems could there be?

luser pushed a commit to luser/rust-bindgen that referenced this issue Mar 27, 2017
Generate better func decls for void returns
@jtojnar
Copy link

jtojnar commented May 7, 2017

I got this error by accidentally omitting > for redirecting output (bindgen header.h bindings.rs). Showing a better error message would be nice.

@fitzgen
Copy link
Member

fitzgen commented Jul 21, 2017

We support multiple headers now.

@fitzgen fitzgen closed this as completed Jul 21, 2017
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

4 participants