macro_rules! c_main {
($runner:ident) => { ... };
($runner:ident -> $int:ident) => { ... };
}
Expand description
Declares main function with C like signature, passing CLI arugments via Args
§Arguments
runner
- Function name to acceptsArgs
instanceint
- Integer type used forargc
and return value. In C it isint
and therefore by default macro uses$crate::int
.
§Return value
C++ main
expects integer return value, therefore it automatically converts to int
type
§Panic
In case of supplied command line arguments contain non-UTF8 string, then terminates.
If printf
is avalable then it prints to stdout
and exits with return code 1
Otherwise it panics.
§Usage
Default int
type`
#![no_main]
fn my_main(args: c_ffi::Args) -> bool {
match args.into_iter().count() {
0 => true,
_ => false,
}
}
c_ffi::c_main!(my_main);