#syntax #function #define #correct #macro-rules #extern #normal

externcfn

macro_rules for define correct extern 'C' functions with an normal syntax

3 stable releases

1.0.2 Oct 20, 2024

#5 in #extern

25 downloads per month

MIT license

6KB

The externcfn macro allows you to define any number of functions with a familiar Rust syntax while seamlessly converting them into C-compatible functions using the C ABI. These functions can be both const and unsafe, accept any number of arguments, and have an optional return type with the function logic defined inside a block. Additionally, the macro supports attaching various attributes like cfg, inline, and doc to the function.

The macro simplifies the creation of C functions by maintaining the ease and clarity of Rust's function definition syntax. It ensures that the generated functions are syntactically correct and directly compatible with other languages that utilize the C ABI.

Dependencies

~97KB