Adding macro definitions for declaring C structures and pointers.
This commit is contained in:
18
src/c_struct.rs
Normal file
18
src/c_struct.rs
Normal 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),+,
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user