Force exporting typedef

Open
#1,122 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
tooling

Research direction

Start by reading how cbindgen handles the export.include key in cbindgen.toml and how it discovers public Rust types referenced by exported items. Define the expected behavior for an unreferenced public typedef, then identify the relevant tests or entry point before implementing it. Done means such a type can be exported without listing each type under export.include.

Written by the indexing model from the issue text.

Description

My rust code defines some public types (functrions) . These types are not referenced by any functions, structures, enums, etc. exported by cbindgen. Still, I would like to export as typedefs in my header (without listing them all under export.include key of cbindgen.toml).

Example of such a type:

pub type ErrorCallbackType = extern "C" fn(*mut c_void, *mut c_char) -> c_void;

... it is not referenced by any code after.

What could I possibly do about it? Maybe annotate them somehow? Something like cbindgen:include (just like we have cbindgen:ignore)?..
Defining some extra symbols just for referenceing these types seems ugly to me.

Dominant language
Rust
Stars
3k
Forks
386
Avg merge
1h 43m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mozilla/cbindgen

All issues in mozilla/cbindgen

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.