1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-11 13:18:43 +02:00

Add minimal no_std example.

This commit is contained in:
Andrew Walbran 2023-02-01 16:24:45 +00:00
parent 27820629e2
commit f71a86d942
2 changed files with 23 additions and 0 deletions

View File

@ -237,6 +237,7 @@
- [Welcome](welcome-bare-metal.md)
- [`no_std`](bare-metal/no_std.md)
- [A minimal example](bare-metal/minimal.md)
- [`core`]()
- [`alloc`]()
- [Microcontrollers]()

22
src/bare-metal/minimal.md Normal file
View File

@ -0,0 +1,22 @@
# A minimal `no_std` program
```rust,editable
#![no_main]
#![no_std]
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_panic: &PanicInfo<'_>) -> ! {
loop {}
}
```
<details>
* This will compile to an empty binary.
* `std` provides a panic handler; without it we must provide our own.
* Depending on the target, you may need to compile with `panic = "abort"` to avoid an error about
`eh_personality`.
</details>