Adding macro definitions for declaring C structures and pointers.

This commit is contained in:
2019-06-25 02:31:18 -04:00
parent 95361a80e2
commit 3bc41bae4f
3 changed files with 35 additions and 0 deletions

18
src/c_struct.rs Normal file
View File

@ -0,0 +1,18 @@
/// Defines a C style structure.
#[macro_export]
macro_rules! c_struct
{
{
$cname: ident
{
$($name: ident: $type: ty);*;
}
} =>
{
#[repr(C)]
pub struct $cname
{
$(pub $name: $type),+,
}
};
}