Workaround for expansion of function-like macros by jbaublitz · Pull Request #2779 · rust-lang/rust-bindgen (original) (raw)
@jbaublitz after testing, I found something interesting.
If I directly include nds.h like
let bindings = bindgen::Builder::default() // The input header we would like to generate // bindings for. .header(format!("{}/libs/libnds/include/nds.h",blocksds_path)) .wrap_static_fns(true) .wrap_static_fns_path("src/arm9_bindings.c") .use_core() .trust_clang_mangling(false) .prepend_enum_name(false) .clang_arg("-mfloat-abi=soft") // Tell cargo to invalidate the built crate whenever any of the // included header files changed. .clang_arg(format!("-I{}/libs/libnds/include",blocksds_path)) .clang_arg(format!("-I{}/libs/dswifi/include",blocksds_path)) .clang_arg(format!("-I{}/libs/maxmod/include",blocksds_path)) .clang_arg(format!("-isystem{}/toolchain/gcc-arm-none-eabi/arm-none-eabi/include",wonderful_path)) .clang_arg("-DARM9") .clang_arg("-D__NDS__") .clang_macro_fallback() .wrap_unsafe_ops(true) // Finish the builder and generate the bindings. .generate() // Unwrap the Result and panic on failure. .expect("Unable to generate bindings");
it works, however, if I include a wrapper.h with the content
#include <nds.h>
#ifdef ARM7
#include <dswifi7.h>
#include <maxmod7.h>
#elif ARM9
#include <dswifi9.h>
#include <maxmod9.h>
#endif
it doesn't work, although it did include the rest of nds.h, it didn't import the macros
that might be a bug
edit:
that seems to occur also when I do that
let bindings = bindgen::Builder::default()
// The input header we would like to generate
// bindings for.
.header(format!("{}/libs/libnds/include/nds.h",blocksds_path))
.header(format!("{}/libs/dswifi/include/dswifi9.h",blocksds_path))
.header(format!("{}/libs/maxmod/include/maxmod9.h",blocksds_path))
so the issue seems caused by the fact to import other headers than just nds.h
it also occurs when wrapper.h only includes nds.h
this is the library for reference
https://github.com/blocksds/libnds/tree/master