Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

What's a main function?

In C programs, there's always a function named main that's called to start the application.

Mynewt OS is written in C, so Mynewt uses the same convention... It expects us to provide a C function named main that is called upon startup.

Our application is in Rust not C. We exposed our Rust function named main as a C function, like this...

extern "C" fn main()

Why is the main function in not

Our Rust Application is actually compiled into a Rust Library that's linked into Mynewt OS.

By convention, a Rust Library must have a file that defines the Rust functions (and optionally, includes other Rust source files).

That's why our Rust main function is in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment