3 ms·
A C header is not needed at runtime, it is purely a way to easily describe the symbols in a library that exist in a (somewhat) type-safe way. It's the lingua fr
by dbaupp 11y ago
A C header is not needed at runtime, it is purely a way to easily describe the symbols in a library that exist in a (somewhat) type-safe way. It's the lingua franca for describing libraries, and tooling (such as Rust's bindgen, or Python's cffi) can consume them to do the setup/create the information necessary to call functions from other languages. This is much nicer than manually trying to transcribe the Rust (or whatever) signatures into your application.
> header files are a Rust-to-C++ issue only
Or... C? (And of course other languages too, as just discussed.)
- Manishearth 11y ago> It's the lingua franca for describing libraries, and tooling (such as Rust's bindgen, or Python's cffi) can consume them to do the setup/create the information necessary to call functions from other languages. Hence the "not necessarily" in my comment. The parent seemed to be painting this as extra unnecessary work; I was saying that a header file is _not_ necessary except for binding to C/C++. If you want to write a C API that will be called from many languages; you should have a header file so that bindgen tools can consume it. If you want an API that will only be called by Python .... not so necessary, you may want a header file anyway but it depends on the situation. > Or... C? Sure, goes without saying :)