-
Notifications
You must be signed in to change notification settings - Fork 373
cbindgen:no-export is ignored #1071
Copy link
Copy link
Closed
Description
My crate uses bindgen to conert C headers to rust bindings, and cbindgen to export rust code to C. Somehow, I am unable to exclude any bindgen-generated code from cbindgen, despite tagging it with /// cbindgen:no-export. A simple reproduction:
src/lib.rs
#[unsafe(no_mangle)]
pub extern "C" fn publish_this(left: u64, right: u64) -> u64 { left + right }
/// cbindgen:no-export
#[unsafe(no_mangle)]
pub extern "C" fn do_not_publish(left: u64, right: u64) -> u64 { left + right }
/// cbindgen:no-export
pub mod ffi {
#[unsafe(no_mangle)]
pub extern "C" fn do_not_publish_in_mod(left: u64, right: u64) -> u64 { left + right }
}build.rs
fn main() {
cbindgen::generate(std::env::var("CARGO_MANIFEST_DIR").unwrap())
.unwrap()
.write_to_file("exported.h");
}Bad output
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
extern "C" {
uint64_t publish_this(uint64_t left, uint64_t right); // <-- this is ok
uint64_t do_not_publish(uint64_t left, uint64_t right); // <-- this is an error
uint64_t do_not_publish_in_mod(uint64_t left, uint64_t right); // <-- this is an error
} // extern "C"Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels