From 6bfc2176187a6fc6fba6315323b0296112330294 Mon Sep 17 00:00:00 2001 From: Aidan Hobson Sayers Date: Fri, 10 Nov 2023 18:03:58 +0000 Subject: [PATCH] Add docs for no-export --- docs.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs.md b/docs.md index f66be1719..d8c863171 100644 --- a/docs.md +++ b/docs.md @@ -263,6 +263,23 @@ pub mod my_interesting_mod; pub mod my_uninteresting_mod; // This won't be scanned by cbindgen. ``` +### No export annotation + +cbindgen will usually emit all items it finds, as instructed by the parse and export config sections. This annotation will make cbindgen skip this item from the output, while still being aware of it. This is useful for a) suppressing "Can't find" errors and b) emitting `struct my_struct` for types in a different header (rather than a bare `my_struct`). + +There is no equivalent config for this annotation - by comparison, the export exclude config will cause cbindgen to not be aware of the item at all. + +Note that cbindgen will still traverse `no-export` structs that are `repr(C)` to emit types present in the fields. You will need to manually exclude those types in your config if desired. + +``` +/// cbindgen:no-export +#[repr(C)] +pub struct Foo { .. }; // This won't be emitted by cbindgen in the header + +#[repr(C)] +fn bar() -> Foo { .. } // Will be emitted as `struct foo bar();` +``` + ### Struct Annotations * field-names=\[field1, field2, ...\] -- sets the names of all the fields in the output struct. These names will be output verbatim, and are not eligible for renaming.