embedded-trainings-2020/embedded-workshop-book/src/parts-embedded-program.md

31 lines
1 KiB
Markdown
Raw Permalink Normal View History

2020-07-08 13:06:49 +00:00
# Parts of an Embedded Program
2020-07-13 15:20:20 +00:00
We will look at the elements that distinguish an embedded Rust program from a desktop program.
✅ Open the `beginner/apps` folder in VS Code.
2020-07-08 13:06:49 +00:00
``` console
$ # or use "File > Open Folder" in VS Code
$ code beginner/apps
```
2020-07-13 15:20:20 +00:00
✅ Then open the `src/bin/hello.rs` file.
## In the file, you will find the following attributes:
### `#![no_std]`
The `#![no_std]` attribute indicates that the program will not make use of the standard library, the `std` crate. Instead it will use the `core` library, a subset of the standard library that does not depend on an underlying operating system (OS).
### `#![no_main]`
2020-07-08 13:06:49 +00:00
The `#![no_main]` attribute indicates that the program will use a custom entry point instead of the default `fn main() { .. }` one.
2020-07-13 15:20:20 +00:00
### `#[entry]`
The `#[entry]` attribute declares the custom entry point of the program. The entry point must be a divergent function whose return type is the never type `!`. The function is not allowed to return; therefore the program is not allowed to terminate.
2020-07-09 10:16:32 +00:00