Skip to content

Commit 53df2d8

Browse files
committed
Pass system header paths to fallback parser
If a macro needed to be parsed using the fallback parser but the macro used items included in a builtin header, the parsing would fail since the location of the header would be unknown.
1 parent 6bbde80 commit 53df2d8

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

bindgen-tests/tests/expectations/tests/macro-fallback-include-builtin.rs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// bindgen-flags: --clang-macro-fallback --allowlist-item TEST
2+
// Ensures that the fallback path for macros doesn't silently
3+
// fail because of builtin headers not being found.
4+
5+
#include <stddef.h>
6+
7+
#define TEST ((size_t)42)

bindgen/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,10 @@ impl Bindings {
871871
for path in search_paths {
872872
if let Ok(path) = path.into_os_string().into_string() {
873873
options.clang_args.push("-isystem".into());
874-
options.clang_args.push(path.into_boxed_str());
874+
options.clang_args.push(path.clone().into_boxed_str());
875+
876+
options.fallback_clang_args.push("-isystem".into());
877+
options.fallback_clang_args.push(path.into_boxed_str());
875878
}
876879
}
877880
}

0 commit comments

Comments
 (0)