Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Later we'll see what cbindgen essentially does is receive a configuration and a Rust library and then spit out a C header (.h) file. One might think that what cbindgen is doing might not be that special and can be done by hand. In which some cases that might be true if the project is simple enough. Though additionally as the cbindgen documentation states:
As might be obvious already, a project needs to be created, in this case, however, it's a library crate (lib.rs) that we need to include rather than a binary crate (main.rs). Additionally, I will need to configure the project for the hardware I need. To make things easier, I grabbed an existing template for a GPIO project I've created in the past and modified it. I simply deleted main.rs and replaced it with an empty lib.rs as a first step. Finally, cbindgen also requires that we add a cbindgen.toml the configuration file which can be empty for starts. Afterward, the project folder tree looks like this: